import { game, ui, _status, ai, lib, get } from "../../../noname.js";
const ec = `extension/云中守望/assets/character/`;
const ea = `ext:云中守望/assets/audio/`;
export const DIY = {
	name: 'swDIY',
	connect: true,
	character: {
		//Q群风云传
		swq_aoliao: {
			sex: "male",
			group: 'shu',
			hp: 3,
			skills: ['swq_zhitian', 'swq_jincui', 'swq_qideng'],
			img: "image/character/sb_sp_zhugeliang.jpg",
			dieAudios: ["sb_sp_zhugeliang"],
		},
		swq_lugushou: {
			sex: "female",
			group: 'key',
			hp: 3,
			skills: ['swq_duannian', 'swq_jifeng', 'swq_juejing'],
			img: `${ec}swq_lugushou.jpg`,
			dieAudios: ["sb_zhenji"],
		},
		swq_xindong: {
			sex: "female",
			group: 'key',
			hp: 3,
			skills: ['swq_qingnian', 'swq_lunqi', 'swq_xinci'],
			img: `${ec}swq_xindong.jpg`,
			dieAudios: ["tenggongzhu"],
		},
		swq_sunyuning: {
			sex: "male",
			group: 'key',
			hp: 4,
			skills: ['swq_wudu', 'swq_yuyin'],
			img: `${ec}swq_sunyuning.jpg`,
			dieAudios: ["key_saya"],
		},
		//异构奇英录
		swyg_jushou: {
			sex: 'male',
			group: 'qun',
			hp: 3,
			skills: ['swyg_jianying', 'swyg_quanlue', 'swyg_shibei'],
			img: `${ec}swyg_jushou.jpg`,
			dieAudios: ["re_jushou"],
		},
		swyg_guojia: {
			sex: 'male',
			group: 'wei',
			hp: 3,
			skills: ['swyg_shisheng', 'swyg_shibai'],
			img: "image/character/ps1059_guojia.jpg",
			dieAudios: ["shen_guojia"],
		},
		swyg_xunyu: {
			sex: 'male',
			group: 'wei',
			hp: 3,
			skills: ['swyg_zaifu', 'swyg_dingce'],
			img: `${ec}swyg_xunyu.jpg`,
			dieAudios: ["shen_xunyu"],
		},
		swyg_caojinyu: {
			sex: 'female',
			group: 'wei',
			hp: 3,
			skills: ['swyg_yuqi', 'swyg_shanshen', 'swyg_xianjing'],
			img: `${ec}swyg_caojinyu.jpg`,
			dieAudios: ["caojinyu"],
		},
		swyg_hanxiandi: {
			sex: 'male',
			group: 'qun',
			hp: 3,
			skills: ['swyg_modi', 'swyg_zhaoling', 'swyg_fuhan', 'swyg_handi'],
			img: `${ec}swyg_hanxiandi.jpg`,
			dieAudios: ["dc_sb_liuxie"],
		},
		swyg_xiaoqiao: {
			sex: 'female',
			group: 'wu',
			hp: 3,
			skills: ['swyg_tianxiang', 'swyg_hongyan'],
			img: `${ec}swyg_xiaoqiao.jpg`,
			dieAudios: ["sb_xiaoqiao"],
		},
		// 二游同人创
		swe_katixiya: {
			sex: 'female',
			group: 'wei',
			hp: 4,
			skills: ['swe_fengdu', 'swe_yijian', "swe_qiyuan"],
			img: `${ec}swe_katixiya.jpg`,
			dieAudios: [`${ea}katixiya/katixiya.mp3`],
		},
		swe_fuludelisi: {
			sex: 'female',
			group: 'wei',
			hp: 4,
			skills: ['swe_jueyi'],
			isUnseen: true,
			img: `${ec}swe_fuludelisi.jpg`,
			dieAudios: [`${ea}katixiya/fuludelisi.mp3`],
		},
/*
		sw_lutiandilang: {
			sex: "male",
			group: 'key',
			hp: 3,
			maxHp: 4,
			skills: ['sw_renjie', 'sw_sanyang', 'sw_luguan', 'sw_xinhuo'],
			img: "image/character/qinlang.jpg",
		},
		sw_hepingshizhelang: {
			sex: "male",
			group: 'key',
			hp: 2,
			maxHp: 2,
			skills: ['sw_gugu', 'sw_heping', 'sw_shangzhuo'],
			trashBin: ['character:qinlang']
		},
		sw_shouwang: {
			sex: "female",
			group: 'key',
			hp: 2,
			maxHp: 4,
			hujia: 2,
			skills: ['sw_tongpin', 'sw_kelian'],
			trashBin: ['character:key_abyusa']
		},
		sw_shenshouwang: {
			sex: "female",
			group: 'shen',
			hp: 3,
			maxHp: 7,
			skills: ['sw_tonghun', 'shiki_omusubi'],
			trashBin: ['character:key_abyusa']
		},
		sw_shenqinlang: {
			sex: "male",
			group: 'shen',
			hp: 4,
			maxHp: 7,
			skills: ['sw_nanchong', 'sw_weige'],
			trashBin: ['character:qinlang']
		},
		sw_gushenlangfeite: {
			sex: "male",
			group: 'shen',
			hp: 3,
			maxHp: 3,
			skills: ['sw_shangshi', 'sw_kaipan'],
			trashBin: ['character:qinlang']
		},
		sw_shenaoliao: {
			sex: "male",
			group: 'shen',
			hp: 3,
			maxHp: 3,
			skills: ['sw_kanpo', 'sw_zhinang'],
			trashBin: ['character:sb_sp_zhugeliang']
		},



 */
	},
	skill: {
		// Q群风云传
		// 奥利奥
		swq_zhitian: {
			audio: ["dczhizhe", 2],
			hiddenCard: function (player, name) {
				if (player.isTempBanned("swq_zhitian")) return false;
				return lib.inpile.includes(name);
			},
			enable: "chooseToUse",
			chooseButton: {
				dialog: function (event, player) {
					var list = [];
					for (var name of lib.inpile) {
						if (get.type(name) != "equip")
							list.push([get.translation(get.type(name)), "", name]);
						if (name == "sha") {
							for (var j of lib.inpile_nature) list.push(["基本", "", "sha", j]);
						}
					}
					return ui.create.dialog("知天", [list, "vcard"]);
				},
				check(button) {
					const player = get.player();
					if(ui.cardPile.hasChildNodes()) {
						const card = ui.cardPile.firstChild;
						if(player.hasValueTarget(card, true, true)) {
							return button.link[2] == get.name(card);
						}
						return false;
					}
					return get.value(button.link);
				},
				filter: function (button, player) {
					return _status.event.getParent().filterCard({ name: button.link[2] }, player, _status.event.getParent());
				},
				backup: function (links, player) {
					return {
						audio: ["dczhizhe", 2],
						popname: true,
						viewAs: { name: links[0][2], nature: links[0][3], isCard: true },
						selectCard: -1,
						filterCard: () => false,
						precontent() {
							player.logSkill("swq_zhitian");
							const cards = get.cards();
							event.result.cards = cards;
							delete event.result.skill;
							game.cardsGotoOrdering(cards);
							if (cards[0].name != event.result.card.name) {
								player.tempBanSkill("swq_zhitian");
								player.loseHp();
							}
						},
					};
				},
				prompt: function (links, player) {
					return "将牌堆顶的牌当做" + (get.translation(links[0][3]) || "") + get.translation(links[0][2]) + "使用";
				},
			},
			group: "swq_zhitian_guanxing",
			subSkill: {
				guanxing: {
					trigger: { player: "changeHp" },
					prompt2: function (event, player) {
						return `观看牌堆顶的${get.cnNumber(player.hp + 2)}张牌，并以任意顺序将其置于牌堆顶或牌堆底`;
					},
					filter: function (event, player) {
						return player.hp + 2 > 0;
					},
					async content(event, trigger, player) {
						const cards = get.cards(player.hp + 2);
						await game.cardsGotoOrdering(cards);
						const next = player.chooseToMove();
						next.set("list", [["牌堆顶", cards.filterInD()], ["牌堆底"]]);
						next.set("prompt", "知天：点击或拖动将牌移动到牌堆顶或牌堆底");
						next.processAI = list => {
							const cards = list[0][1],
								player = _status.event.player;
							const top = [];
							const judges = player.getCards("j");
							let stopped = false;
							if (!player.hasWuxie()) {
								for (let i = 0; i < judges.length; i++) {
									const judge = get.judge(judges[i]);
									cards.sort((a, b) => judge(b) - judge(a));
									if (judge(cards[0]) < 0) {
										stopped = true;
										break;
									} else {
										top.unshift(cards.shift());
									}
								}
							}
							let bottom;
							if (!stopped) {
								cards.sort((a, b) => get.value(b, player) - get.value(a, player));
								while (cards.length) {
									if (get.value(cards[0], player) <= 5) break;
									const card = cards.shift()
									if (player.hasValueTarget(card, true, true)) top.unshift(card);
								}
							}
							bottom = cards;
							return [top, bottom];
						};
						const {
							result: { moved },
						} = await next;
						const top = moved[0];
						const bottom = moved[1];
						top.reverse();
						game.cardsGotoPile(top.concat(bottom), ["top_cards", top], (event, card) => {
							if (event.top_cards.includes(card)) return ui.cardPile.firstChild;
							return null;
						});
						player.popup(get.cnNumber(top.length) + "上" + get.cnNumber(bottom.length) + "下");
						game.log(player, "将" + get.cnNumber(top.length) + "张牌置于牌堆顶");
						await game.delayx();
					},
				},
				backup: {},
			},
			ai: {
				order: 12,//秀死你们
				result: {
					player: 1,
				},
				save: true,
				respondSha: true,
				respondShan: true,
				respondTao: true,
				skillTagFilter(player, tag, arg) {
					switch (tag) {
						case "save":
						case "respondTao":
						case "respondShan":
						case "respondSha":
							return !player.isTempBanned("swq_zhitian");
					}
				},
			},
		},
		swq_jincui: {
			audio: ["dcjincui", 2],
			enable: 'phaseUse',
			skillAnimation: true,
			animationColor: 'orange',
			limited: true,
			logTarget: "target",
			filterTarget(card, player, target) {
				return player != target;
			},
			ai2(target) {
				const player = get.player();
				return get.effect(target, { name: "sha" }, player, player) > 0 && get.attitude(player, target) < 0;
			},
			async content(event, trigger, player) {
				const { target } = event;
				await player.awakenSkill("swq_jincui");
				await player.loseHp();
				let cards = get.cards(7);
				game.cardsGotoOrdering(cards);
				await player.showCards(cards, get.translation(player) + '的【尽瘁】牌展示');
				while(target.isAlive() && cards.length) {
					let have = 0;
					for (let card of cards) {
						if (card.name == 'sha' && player.canUse(card, target, false)) {
							await player.useCard(card, target, false);
							cards.remove(card);
							have = 1;
							break;
						};
					}
					if(!have) break;
				}
				if (cards.length) {
					const result = await player.chooseButton(['###【尽瘁】###<div class="text center">你可以选择获得一张牌</div>', [cards, 'card']], false)
						.set("ai", button => {
							const player = get.player(),
								card = button.link;
							return player.getUseValue(card) + 0.01;
						})
						.forResult();
					if (result?.links?.length) {
						player.gain(result.links, 'gain2');
					};
				};
			},
			subSkill: {
				machi: {
					charlotte: true,
					forced: true,
					popup: false,
					trigger: {
						global: ["washCard", "die"],
					},
					filter: function (event, player) {
						return player.hasSkill("swq_jincui", null, false, false);
					},
					content: function () {
						player.addSkill("swq_jincui_risutoa");
					},
				},
				risutoa: {
					charlotte: true,
					forced: true,
					popup: false,
					trigger: { global: "phaseAfter" },
					content: function () {
						if (player.awakenedSkills.includes("swq_jincui")) {
							player.restoreSkill("swq_jincui");
							game.log(player, "重置了", "#g【尽瘁】");
						}
						player.removeSkill("swq_jincui_risutoa");
					},
				},
			},
			ai: {
				order: 9,
				expose: 1,
				threaten: 1.2,
			}
		},
		swq_qideng: {
			init(player, skill) {
				player.addMark(skill, 7);
				player.updateMarks(skill);
			},
			audio: ["dcqingshi", 2],
			mark: true,
			marktext: "灯",
			intro: {
				name: "七星灯",
				content: "当前有#个灯",
			},
			onremove: true,
			trigger: {
				player: "dyingBegin",
			},
			forced: true,
			filter(event, player) {
				return event.getParent(2)?.name != "swq_qideng";
			},
			async content(event, trigger, player) {
				if (player.countMark("swq_qideng") > 0) {
					const num = 1 - player.getHp(true);
					if(num > 0) {
						player.removeMark("swq_qideng", num);
						await player.recoverTo(1);
					}
				}
				else {
					await player.loseHp();
				}
			},
			ai: {
				threaten: function(player, target) {
					if(player.countMark("swq_qideng") > 1) return (1 / player.countMark("swq_qideng")) + 0.4;
					else return 1.5;
				}
			}
		},
		// 陆古寿
		swq_duannian: {
			audio: "sbluoshen",
			persevereSkill: true,
			limited: true,
			skillAnimation: true,
			animationColor: "thunder",
			trigger: { player: "dyingAfter" },
			check(event, player) {
				//是的孩子们我有天眼
				return !game.hasPlayer(current => {
					return get.attitude(current, player) > 1 &&
						current.canSave(player)
				}) || game
					.getAllGlobalHistory("everything", evt => {
						return evt.name == "dying" && evt.player == player;
					})
					.length >= 2
			},
			async content(event, trigger, player) {
				player.awakenSkill(event.name);
				const controlDeleteNum = player.getStorage("swq_duannian_dnum", 0);
				let list = [
					["draw", `摸${Math.max(0, 3 - player.getStorage("swq_duannian_dnum", 0))}张牌`],
					["gain", `获得一名其他角色的一个技能`],
					["reset", `重置该技能并删除该技能最后一个选项`],
					["level", `升级〖讥讽〗`],
				];
				list.length = list.length - controlDeleteNum;
				const num = Math.min(game
					.getAllGlobalHistory("everything", evt => {
						return evt.name == "dying" && evt.player == player;
					})
					.length,
					list.length
				)
				const result = await player
					.chooseButton([
						"###" + get.prompt("swq_duannian") + `###<div class="text center">选择依次执行至多${get.cnNumber(num)}项</div>`,
						[
							list,
							"textbutton"
						]
					],
						[1, num])
					.set("num", num)
					.set("ai", button => {
						const player = get.player();
						var num = 0;
						const priority = {
							draw: () => {
								return Math.max(0, 4 - player.getStorage("swq_duannian_dnum", 0))
							},
							gain: () => {
								const skills = game.players.map(p => p.getSkills(null, false, false).map(c => [p, c])).flat(1)
								skills.randomSort();
								skills.sort((a, b) => get.skillRank(b[1], "inout") - get.skillRank(a[1], "inout"));
								return get.skillRank(skills[0][1], "inout") * 2.8;// 1.0 - 2.0 左右
							},
							reset: () => {
								return get.event("num") == 1 ? 0 : 10;
							},
							level: () => {
								return 5.6
							},
						};
						return priority[button.link]() || 0;
					})
					.set('complexSelect', true)
					.forResult();
				if (result?.bool && result?.links?.length) {
					if(result?.links?.includes("draw")) {
						await player.draw(Math.max(0, 4 - player.getStorage("swq_duannian_dnum", 0)));
					}
					if(result?.links?.includes("gain")) {
						const result2 = await player
							.chooseTarget(
								"断念：获得一名其他角色的一个技能",
								(card, player, target) => {
									return target !== player && target.getSkills(null, false, false).length
								},
								true
							)
							.set("ai", target => {
								const skills = game.players.map(p => p.getSkills(null, false, false).map(c => [p, c])).flat(1)
								skills.randomSort();
								skills.sort((a, b) => get.skillRank(b[1], "inout") - get.skillRank(a[1], "inout"));
								return skills[0][0];
							})
							.forResult();
						if(result2?.targets && result2?.targets.length) {
							const tar = result2.targets[0];
							const targetSkills = tar.getSkills(null, false, false).filter(skill => {
								const info = get.info(skill);
								if (!info || info.charlotte || !get.skillInfoTranslation(skill, player).length) return false;
								return true;
							});
							if (!targetSkills || targetSkills.length == 0) return;
							player.line(tar);
							const control = await player
								.chooseControl(targetSkills)
								.set(
									"choiceList",
									targetSkills.map(skill => {
										return `<div class="skill">【${get.translation(lib.translate[skill + "_ab"] || get.translation(skill).slice(0, 2))}】</div><div>${get.skillInfoTranslation(skill, tar)}</div>`;
									})
								)
								.set("displayIndex", false)
								.set("prompt", "断念：选择获得一个技能")
								.set("tar", tar)
								.set("ai", (event) => {
									const skills = get.event("tar").getSkills(null, false, false)
									skills.randomSort();
									skills.sort((a, b) => get.skillRank(b, "inout") - get.skillRank(a, "inout"));
									return skills[0];
								})
								.forResultControl();
							await player.addSkills(control);
						}
					}
					if(result?.links?.includes("reset")) {
						player.restoreSkill("swq_duannian");
						game.broadcastAll((player, num) => {
							player.setStorage("swq_duannian_dnum", num + 1);
						}, player, player.getStorage("swq_duannian_dnum", 0))
					}
					if(result?.links?.includes("level")) {
						game.broadcastAll((player) => {
							player.setStorage("swq_jifeng", 1);
						}, player)
					}
				}
			},
			ai: {
				threaten: 0.9,
			}
		},
		swq_jifeng: {
			audio: "qingguo_sb_zhenji",
			enable: "phaseUse",
			usable: Infinity,
			derivation: ["swq_jifeng_lv2"],
			logTarget: "target",
			filter(event, player) {
				return game.hasPlayer(target => lib.skill.swq_jifeng.filterTarget(null, player, target));
			},
			filterTarget(event, player, target) {
				return player.canCompare(target) && !target.hasSkill("swq_jifeng_baiban") && !target.hasSkill("swq_jifeng_fengyin");
			},
			onremove(player, skill) {
				game.players.forEach(current => {
					current.removeSkill("swq_jifeng_baiban");
				});
			},
			ai2(target) {
				const player = get.player();
				return -get.attitude(player, target) + 1;
			},
			async content(event, trigger, player) {
				const { target } = event;
				await player.draw(1 + player.getStorage("swq_jifeng", 0))
				if(player.countCards('h') <= 0) {
					player.addSkill("swq_jifeng_baiban")
					event.finish();
				}
				const result = await player.chooseToCompare(target)

					.forResult();
				const winsay = ["就这？就这？", `肺雾${target.nickname ? target.nickname.slice(0, 4) : get.translation(target.name)}`, "不玩神山识玩什么？"];
				const losesay = ["闹麻了", "感觉被做局了", "唉，孩子们"];
				if (result?.bool) {
					const { winner, num1, num2 } = result
					if(winner === player) {
						if(player.getStorage("swq_jifeng", 0) == 0) {
							target.addSkill("swq_jifeng_baiban")
						}
						else {
							target.addSkill("swq_jifeng_fengyin")
						}
						player.chat(winsay.randomGet())
					}
					else {
						player.addSkill("swq_jifeng_baiban")
						player.chat(losesay.randomGet())
					}
				}
				else {
					player.addSkills("swq_jifeng_baiban")
					player.chat(losesay.randomGet())
				}
				if(player.getHistory("useSkill", evt => {
					return evt.skill == event.name;
				}).length == 1) {
					player.when({
						player: "phaseBegin",
					}).then(() => {
						game.players.forEach(current => {
							current.removeSkills(["swq_jifeng_baiban", "swq_jifeng_fengyin"]);
						});
					})
				}
			},
			subSkill: {
				baiban: {
					popup: false,
					init: function (player, skill) {
						player.addSkillBlocker(skill);
						player.addTip(skill, "非锁定技失效");
					},
					onremove: function (player, skill) {
						player.removeSkillBlocker(skill);
						player.removeTip(skill);
					},
					charlotte: true,
					skillBlocker: function (skill, player) {
						return !lib.skill[skill].persevereSkill && !lib.skill[skill].charlotte && !get.is.locked(skill, player);
					},
					mark: true,
					marktext: "讥",
					intro: {
						content: function (storage, player, skill) {
							var list = player.getSkills(null, false, false).filter(function (i) {
								return lib.skill.fengyin.skillBlocker(i, player);
							});
							if (list.length) return "失效技能：" + get.translation(list);
							return "无失效技能";
						},
					},
				},
				fengyin: {
					popup: false,
					init(player, skill) {
						player.addSkillBlocker(skill);
						player.addTip(skill, "讥讽 技能失效");
					},
					onremove(player, skill) {
						player.removeSkillBlocker(skill);
						player.removeTip(skill);
					},
					inherit: "baiban",
					marktext: "讥",
				},
			},
			ai: {
				order: 10,
				result: {
					player: 1,
				}
			},
		},
		swq_juejing: {
			init: () => {
				game.addGlobalSkill("swq_juejingGlobal");
			},
			ai: {
				threaten: function(player, target) {
					if(!player.hasSkill("swq_jifeng_baiban") && player.getHp() <= 1) return 0.5;
					else return 1;
				}
			}
		},
		swq_juejingGlobal: {
			trigger: { player: "dying" },
			firstDo: true,
			ruleSkill: true,
			filter(event, player) {
				const skills = player.getSkills(null, false, false).slice(0)
				if(player.getHistory("useSkill", evt => {
					return evt.skill == "swq_juejingGlobal";
				}).length > 10) return false;
				return skills.includes("swq_juejing") && !game.filterSkills(skills, player).includes("swq_juejing")
			},
			async content(event, trigger, player) {
				await player.recoverTo(1);
				await player.draw(2);
				await player.removeSkills("swq_jifeng_baiban");
			},
		},
		// 心动
		swq_qingnian: {
			mark: true,
			marktext: "☯",
			//popup: false,
			zhuanhuanji(player, skill) {
				player.storage[skill] = !player.storage[skill];
				player.changeSkin({ characterName: "swq_xindong" }, "swq_xindong" + (player.storage[skill] ? "_shadow" : ""));
			},
			intro: {
				content(storage) {
					if (!storage) return "当你不因使用而失去手牌时，你可以将手牌摸至体力上限并随机明置一名其他角色的X张手牌。（X为你本次失去牌的数量）";
					return "当你不因使用而失去手牌时，你可以明置一张手牌并弃置一名其他角色的至多X张牌，然后你将被弃置的牌以任意顺序置于牌堆顶或牌堆底。（X为你本次失去牌的数量）";
				},
			},
			audio: "xingchong",
			trigger: {
				player: "loseAfter",
				global: ["equipAfter", "addJudgeAfter", "gainAfter", "loseAsyncAfter", "addToExpansionAfter"],
			},
			filter(event, player) {
				if (player.getStorage("swq_qingnian_used").includes(player.storage.swq_qingnian ? "yin" : "yang")) return false;
				if (event.name == "lose" && event.getParent().name == "useCard") return false;
				if (player.storage.swq_qingnian && player.countCards("h", function (card) {
					return !get.is.shownCard(card);
				}) <= 0) return false;
				return event.getl(player)?.hs?.length;
			},
			check(event, player) {
				return true;
			},
			async cost(event, trigger, player) {
				const num = trigger.getl(player)?.hs?.length || 1;
				if (player.storage.swq_qingnian) {
					event.result = await player.chooseCardTarget({
						filterCard(card) {
							return !get.is.shownCard(card);
						},
						filterTarget(card, player, target) {
							return target != player && target.countCards('he');
						},
						selectCard: 1,
						position: "h",
						prompt: get.prompt("swq_qingnian"),
						prompt2: "明置" + get.cnNumber(1) + `张手牌并弃置一名其他角色的至多${num}张牌。`,
						ai1(card) {
							return 15 - get.value(card);
						},
						ai2(target) {
							var player = get.player();
							return -get.attitude(player, target) + 1;
						},
					}).forResult();
				} else {
					event.result = await player.chooseTarget(1, get.prompt("swq_qingnian"), `将手牌摸至体力上限并随机明置一名其他角色的${num}张手牌`,
						function (card, player, target) {
							return target != player && target.countCards('h', card => !get.is.shownCard(card));
						})
						.set("ai", function (target) {
						var player = get.player();
						return -get.attitude(player, target) + 1;
						})
						.forResult();
				}
			},
			logTarget: "targets",
			async content(event, trigger, player) {
				const num = trigger.getl(player)?.hs?.length || 1;
				const target = event?.targets?.[0];
				//await player.logSkill("swq_qingnian", target);
				player.addTempSkill("swq_qingnian_used");
				player.markAuto("swq_qingnian_used", [player.storage.swq_qingnian ? "yin" : "yang"]);
				player.changeZhuanhuanji("swq_qingnian");
				if (player.storage.swq_qingnian) {
					await player.drawTo(player.maxHp);
					//await player.line(target);
					const cards = target.getCards('h', card => !get.is.shownCard(card)).randomGets(num);
					await target.addShownCards(cards, "visible_swq_qingnian");
					await target.showCards(cards, get.translation(player) + "对" + get.translation(target) + `发动了【${get.translation("swq_qingnian")}】`);
				} else {
					await player.addShownCards(event.cards, "visible_swq_qingnian");
					await player.showCards(event.cards);
					const result = await player.discardPlayerCard(target, "he", false, [1, num]).forResult();
					if(result?.bool && result?.cards?.length) {
						const { moved } = await player
							.chooseToMove()
							.set("list", [["牌堆顶", result?.cards], ["牌堆底"]])
							.set("prompt", "倾念：将这些牌置于牌堆顶或牌堆底")
							.set("processAI", function (list) {
								var cards = list[0][1],
									player = _status.event.player;
								var target = _status.currentPhase?.next;
								var att = get.sgn(get.attitude(player, target));
								var top = [];
								var stopped = false;
								if (target) {
									var judges = target.getCards("j");
									if (player != target || !target.hasWuxie()) {
										for (var i = 0; i < judges.length; i++) {
											var judge = get.judge(judges[i]);
											cards.sort(function (a, b) {
												return (judge(b) - judge(a)) * att;
											});
											if (judge(cards[0]) * att < 0) {
												stopped = true;
												break;
											} else {
												top.unshift(cards.shift());
											}
										}
									}
								}
								var bottom;
								if (!stopped) {
									cards.sort(function (a, b) {
										return (get.value(b, player) - get.value(a, player)) * att;
									});
									while (cards.length) {
										if (get.value(cards[0], player) <= 5 == att > 0) break;
										top.unshift(cards.shift());
									}
								}
								bottom = cards;
								return [top, bottom];
							})
							.forResult();
						const top = moved[0];
						const bottom = moved[1];
						top.reverse();
						game.cardsGotoPile(top.concat(bottom), ["top_cards", top], (event, card) => {
							if (event.top_cards.includes(card)) return ui.cardPile.firstChild;
							return null;
						});
						player.popup(get.cnNumber(top.length) + "上" + get.cnNumber(bottom.length) + "下");
						game.log(player, "将" + get.cnNumber(top.length) + "张牌置于牌堆顶");
						await game.delayx();
					}
				}
			},
			group: "swq_qingnian_change",
			subSkill: {
				change: {
					audio: "xingchong",
					trigger: {
						global: "phaseBefore",
						player: "enterGame",
					},
					filter(event, player) {
						return event.name != "phase" || game.phaseNumber == 0;
					},
					prompt2(event, player) {
						return "切换【倾念】为状态" + (player.storage.swq_qingnian ? "阳" : "阴");
					},
					check: () => true,
					content() {
						player.changeZhuanhuanji("swq_qingnian");
					},
				},
				used: { charlotte: true, onremove: true },
			},
			ai: {
				expose: 0.4,
				result: {
					player: 2,
					target: -2,
				},
				noh: true,
				skillTagFilter(player, tag, arg) {
					if(tag == "noh") {
						if (player.getStorage("swq_qingnian_used").includes(player.storage.swq_qingnian ? "yin" : "yang")) return false;
						if (player.storage.swq_qingnian) return !(player.countCards('h') >= 1);
						return true;
					}
				},
			},
		},
		swq_lunqi: {
			filter(event, player) {
				return player.countCards("h", card => lib.filter.cardDiscardable(card, player, "swq_lunqi"));
			},
			audio: "liunian",
			usable: 1,
			enable: "phaseUse",
			popup: false,
			chooseButton: {
				dialog() {
					return ui.create.dialog("###论契###" + get.translation("swq_lunqi_info"));
				},
				chooseControl(event, player) {
					var suits = [],
						hs = player.getCards("h", card => lib.filter.cardDiscardable(card, player, "swq_lunqi"));
					for (var i of hs) {
						var suit = get.suit(i, player);
						suits.add(suit);
					}
					suits.push("cancel2");
					return suits;
				},
				check(event, player) {
					var suits = [],
						hs = player.getCards("h", card => lib.filter.cardDiscardable(card, player, "swq_lunqi"));
					for (var i of hs) {
						var suit = get.suit(i, player);
						suits.add(suit);
					}
					if(!suits?.length) return false;
					const arr = suits.map(x => [x, suits.filter(y => y === x).length])
						.sort((a, b) => b[1] - a[1])
					if(player.storage.swq_qingnian) {
						//需要保留至少一张手牌进行明置
						const num = player.countCards('h');
						for(let i in arr) {
							if(arr[i][1] != num) return arr[i][0];
						}
						return false;
					}
					else {
						return arr[0][0];
					}
				},
				backup(result, player) {
					return {
						//audio: "sbfanjian",
						suit: result.control,
						discard: false,
						lose: false,
						delay: false,
						async content(event, trigger, player) {
							const suit = get.info(event.name)?.suit;
							const cards = player.getCards("h", card => get.suit(card, player) == suit);
							await player.modedDiscard(cards);
							await player.line(game.filterPlayer())
							await player
								.chooseToDebate(
									game.filterPlayer()
								)
								.set("callback", async event => {
									const result = event.debateResult;
									if (result?.bool) {
										const { black, red } = result;
										let num = Math.abs((black?.length || 0) - (red?.length || 0))
										if(num === 0) return;
										const res2 = await player.chooseTarget(2, get.prompt("swq_lunqi"), `你可以选择两名角色交换他们的至多${num}张手牌`, false, function (card, player, target) {
											return target.countCards("h") > 0;
										}).set("ai", function (target) {
											const player = get.player();
											let num = player.countCards('h', card => 7 - get.value(card));
											if (player.storage.swq_qingnian &&
												!player.getStorage("swq_qingnian_used").includes(player.storage.swq_qingnian ? "yin" : "yang") &&
												num == player.countCards('h') &&
												num > 0
											) {
												num--;//阴状态保留至少一张手牌，其他的无所谓了
											}
											if (ui.selected?.targets?.length == 0) {
												if(target === player) {
													return !player.getStorage("swq_qingnian_used").includes(player.storage.swq_qingnian ? "yin" : "yang") ? 100 : num * 2.5;
												}
												else return get.attitude(player, target);
											}
											else {
												return -get.attitude(player, target) || (!player.getStorage("swq_qingnian_used").includes(player.storage.swq_qingnian ? "yin" : "yang") && !player.storage.swq_qingnian ? Math.random() : 0);
											}
										}).forResult();
										if(res2?.bool && res2?.targets.length == 2) {
											res2.targets.sortBySeat();
											const p1 = res2.targets[0],
												p2 = res2.targets[1];
											await player.line(p1);
											await player.line(p2);
											num = Math.min(num, Math.min(p1.countCards('h'), p2.countCards('h')));
											const links1 =
												await player.choosePlayerCard(p1, true, "h", [1, num], `论契：选择${get.translation(p1) + (p1 == player ? "(你)" : "")}的至多${num}张手牌`)
													.set("ai", (button) => {
														const player = get.player();
														const target = get.event("targetx");
														const num = get.event("ainum");
														const card = button.link;
														if(target === player) {
															if(ui.selected?.buttons?.length < num) {
																return 7 - get.value(card);
															}
															else {
																return -10;
															}
														}
														else {
															if(get.is.shownCard(card)) {
																return (7 - get.value(card)) * Math.sign(get.attitude(player, target));
															}
															else {
																return (1 + Math.random()) * 4 * Math.sign(get.attitude(player, target));
															}
														}
													})
													.set("targetx", p1)
													.set("ainum", () => {
														let num = player.countCards('h', card => 7 - get.value(card));
														if (player.storage.swq_qingnian &&
															!player.getStorage("swq_qingnian_used").includes(player.storage.swq_qingnian ? "yin" : "yang") &&
															num == player.countCards('h') &&
															num > 0
														) {
															num--;//阴状态保留至少一张手牌，其他的无所谓了
														}
														return num;
													})
													.forResultLinks();
											if (!links1?.length) return;
											const links2 =
												await player.choosePlayerCard(p2, true, "h", links1.length, `论契：选择${get.translation(p2) + (p2 == player ? "(你)" : "")}的${links1.length}张手牌交换`)
													.set("ai", (button) => {
														const player = get.player();
														const target = get.event("targetx");
														const card = button.link;
														if(get.is.shownCard(card)) {
															return (7 - get.value(card)) * Math.sign(get.attitude(player, target));
														}
														else {
															return (1 + Math.random()) * 4 * Math.sign(get.attitude(player, target));
														}
													})
													.set("targetx", p2)
													.forResultLinks();
											if (!links2?.length) return;
											await p1.swapHandcards(p2, links1, links2);
											await game.delayex();
										}
									}
								});
						},
					};
				},
			},
			group: "swq_lunqi_debate",
			subSkill: {
				backup: {},
				debate: {
					//audio: 2,
					trigger: {
						player: "chooseToDebateBegin",
					},
					charlotte: true,
					forced: true,
					direct: true,
					filter(event, player) {
						if (!event.list.includes(player)) return false;
						if (event.fixedResult?.some(key => key[0] == player)) return false;
						return event?.getParent("swq_lunqi_backup").name == "swq_lunqi_backup" && player.countCards("h", card => get.is.shownCard(card)) >= 1;
					},
					async content(event, trigger, player) {
						const result = await player.chooseCard(1, "本次议事你仅能使用展示的手牌", true, (card) => {
							return get.is.shownCard(card);
						}).forResult();
						if (!trigger.fixedResult) trigger.fixedResult = [];
						trigger.fixedResult.push([player, result.cards[0]]);
					},
				},
			},
			ai: {
				order: 2,
				result: {
					player: 2,
				},
			},
		},
		swq_xinci: {
			audio: "zhenge",
			zhuSkill: true,
			trigger: {
				global: "phaseBegin",
			},
			filter(event, player) {
				return (
					player != event.player &&
					event.player.group == "key" &&
						player.countCards('h')
				);
			},
			async cost(event, trigger, player) {
				event.result = await player
					.chooseCard(
						get.prompt2("swq_xinci"),
						"h",
						1,
						false
					)
					.set("target", trigger.player)
					.set("ai", card => {
						const { player, target } = get.event();
						if (get.attitude(player, target) > 0 && player.getHp() > 2 && target.isDamaged() && player.countCards('h') >= 2) return 11 - get.value(card);
						return 0;
					})
					.forResult();
			},
			async content(event, trigger, player) {
				await player.give(event.cards, trigger.player);
				await trigger.player.addShownCards(event.cards, "visible_swq_xinci");
				await trigger.player.showCards(event.cards);
				trigger.player.addTempSkill("swq_xinci_check");
				trigger.player.markAuto("swq_xinci_check", [player]);
			},
			subSkill: {
				check: {
					charlotte: true,
					trigger: { player: "phaseEnd" },
					firstDo: true,
					forced: true,
					popup: false,
					onremove: true,
					filter(event, player) {
						return !player.getHistory("recover")?.length;
					},
					async content(event, trigger, player) {
						var targets = player.getStorage("swq_xinci_check");
						targets.sortBySeat();
						for (var i of targets) {
							if (i.isIn()) {
								await i.line(player);
								await i.logSkill("swq_xinci");
								await i.loseHp();
							}
						}
						await player.removeSkill("swq_xinci_check");
					},
				},
			},
		},
		// 孙玉凝
		swq_wudu: {
			audio: "saya_shouji",
			mod: {
				cardRecastable(card) {
					if (get.type(card) == "identity") return true;
				},
			},
			trigger: {
				global: "phaseBefore",
				player: "enterGame",
			},
			forced: true,
			filter(event, player) {
				return (event.name != "phase" || game.phaseNumber == 0) && game.hasPlayer(p => p.identity);
			},
			video(player, info) {
				for (var name of info[0]) {
					lib.skill.swq_wudu.createCard(name);
					lib.inpile.add("swq_wudu_" + name);
				}
			},
			async content(event, trigger, player) {
				//game.addGlobalSkill("tianzuo_global");
				let identityList = [...new Set(game.filterPlayer().map(p => p.identity))];
				game.addVideo("skill", player, ["swq_wudu", [identityList]]);
				game.broadcastAll(
					function (list) {
						for (const name of list) {
							lib.skill.swq_wudu.createCard(name);
							lib.inpile.add("swq_wudu_" + name);
						}
					},
					identityList
				);
				var cards = [];
				identityList.forEach(identity => {
					for (var i = 4; i < 12; i++) {
						cards.push(game.createCard2("swq_wudu_" + identity, ["club", "spade", "diamond", "heart"][i%4], i));
					}
				})
				await game.delayx();
				game.cardsGotoPile(cards, () => {
					return ui.cardPile.childNodes[get.rand(0, ui.cardPile.childNodes.length - 1)];
				});
			},
			createCard(name) {
				if (!_status.postReconnect.swq_wudu)
					_status.postReconnect.swq_wudu = [
						function (list) {
							for (var name of list) {
								lib.skill.swq_wudu.createCard(name);
								lib.inpile.add("swq_wudu_" + name);
							}
						},
						[],
					];
				_status.postReconnect.swq_wudu[1].add(name);
				if (lib.card["swq_wudu_" + name]) return;
				lib.translate["swq_wudu_" + name] = (get.translation(name + "2") == name + "2" ? get.translation(name) : (get.translation(name + "2") || get.translation(name)));
				var info = lib.character[name];
				var card = {
					global: "swq_wudu_identity",
					fullskin: true,
					//cardimage: "identity_" + name,
					image: "ext:../image/card/identity_" + name + ".jpg",
					type: "identity",
					savable(card, player, dying) {
						return dying == player && player.identity == card.name.replace(/^swq_wudu_/, "");
					},
					toself: true,
					ai: {
						basic: {
							useful: (card, i) => {
								const player = _status.event.player;
								if(player?.identity != get.name(card, player).replace(/^swq_wudu_/, "")) return 0;
								if (player.hp > 1) {
									if (i === 0) return 2;
									return 0;
								}
								if (i === 0) return 5.3;
								return 2;
							},
							value: (card, player, i) => {
								if(player?.identity != get.name(card, player).replace(/^swq_wudu_/, "")) return 0;
								if (player.hp > 1) {
									if (i === 0) return 2.5;
									return 0;
								}
								if (i === 0) return 5.3;
								return 2;
							},
						},
						result: {
							target: (player, target, card) => {
								if(target?.identity != get.name(card, player).replace(/^swq_wudu_/, "")) return 0;
								if (target && target.isDying()) return 2;
								return 0;
							},
						},
						tag: {
							save: 1,
							recover: 0.1,
						},
						expose: 1,//使用此牌必定暴露身份
					},
					selectTarget: -1,
					filterTarget(card, player, target) {
						return target == player && target.hp < target.maxHp;
					},
					modTarget(card, player, target) {
						return target.hp < target.maxHp;
					},
					content() {
						target.recover();
					},
				};
				lib.translate["swq_wudu_" + name + "_info"] = "①当你摸到此牌时，若你的身份和牌名相同，你失去1点体力。②当你处于濒死状态时，若你的身份和牌名相同，可以对你自己使用，回复1点体力。";
				// var append = "";
				// lib.translate["swq_wudu_" + name + "_append"] = append;
				lib.card["swq_wudu_" + name] = card;
				//lib.card["identity_" + name] ??= { image: "identity_" + name };
			},
			group: "swq_wudu_use",
			subSkill: {
				use: {
					enable: "phaseUse",
					usable: 1,
					filter(){
						return game.hasPlayer(p => p.identity);
					},
					async content(event, trigger, player) {
						const numbers = Array.from({ length: 13 }).map((_, i) => get.strNumber(i + 1));
						const identityList = [...new Set(game.filterPlayer().map(p => p.identity))].map(p => [p, get.translation(p + '2') || get.translation(p)]);
						const result = await player
							.chooseButton(
								[
									"###巫毒###" + `<div class="text center">向牌堆中添加四张任意花色和点数的一种身份牌</div>`,
									[identityList, "tdnodes"],
									[
										lib.suit
											.slice()
											.reverse()
											.map(i => [i, get.translation(i)]),
										"tdnodes",
									],
									[numbers, "tdnodes"],
								],
								3
							)
							.set("filterButton", button => {
								return !ui.selected.buttons.some(but => {
									return [get.event("identityList").map(identity => identity?.[0]), lib.suit, get.event("numbers")].some(list => list.includes(but.link) && list.includes(button.link));
								});
							})
							.set("numbers", numbers)
							.set("identityList", identityList)
							.set("forced", true)
							.set("ai", (button) => {
								const player = get.player();
								const link = button.link;
								const lists = [get.event("identityList").map(identity => identity?.[0]), lib.suit, get.event("numbers")]
								if(lists[0].includes(link)) {
									debugger
									return (game.hasPlayer(p => p.identity != player.identity && p.identity == link && (get.mode() == "identity" ? get.realAttitude(player, p) < 0 : get.rawAttitude(player, p) < 0)) + 0.1) * Math.random();
								}
								else return Math.random();
							})
							.forResult();
						if(result?.bool && result?.links?.length) {
							const lts = result.links.sort((a, b) => {
								return lib.suit.includes(a) + (numbers.includes(a) ? 2 : 0) - (lib.suit.includes(b) + (numbers.includes(b) ? 2 : 0));
							});
							const cardname = lts[0];
							if(!lib.inpile.includes("swq_wudu_" + cardname)) {
								game.addVideo("skill", player, ["swq_wudu", [[cardname]]]);
								game.broadcastAll(
									function (list) {
										for (const name of list) {
											lib.skill.swq_wudu.createCard(name);
											lib.inpile.add("swq_wudu_" + name);
										}
									},
									[cardname]
								);
							}
							var cards = [];
							for (var i = 0; i < 4; i++) {
								cards.push(game.createCard2("swq_wudu_" + cardname, lts[1], get.numString(lts[2])));
							}
							await game.delayx();
							game.cardsGotoPile(cards, () => {
								return ui.cardPile.childNodes[get.rand(0, ui.cardPile.childNodes.length - 1)];
							});
							player.popup(get.translation(cards?.[0]).replace(/[【】]/g, ""));
							game.log("#b" + get.translation(player), "向牌堆中添加了", "#y" + get.translation(cards));
						}
					},
					ai: {
						order: 6,
						result: {
							player: 1,
						},
					}
				},
			},
		},
		swq_wudu_identity: {
			trigger: {
				player: "gainAfter",
			},
			cardSkill: true,
			direct: true,
			filter(event, player) {
				if (event.getParent().name != "draw") return false;
				let hs = player.getCards("h");
				for (let card of event.getg(player)) {
					if (get.name(card, player).slice(0, 9) == "swq_wudu_" && hs.includes(card)
						&& get.name(card, player).replace(/^swq_wudu_/, "") == player?.identity
						&& !player.hasSkill("swq_wudu")
					) return true;
				}
				return false;
			},
			content() {
				let num = 0;
				for (let card of trigger.getg(player)) {
					if (get.name(card, player).slice(0, 9) == "swq_wudu_"
						&& get.name(card, player).replace(/^swq_wudu_/, "") == player?.identity
						&& !player.hasSkill("swq_wudu")
					) num++;
				}
				game.log("#b" + get.translation(player), "由于摸到了自己的身份牌，失去了", "#y" + num, "点体力");
				player.loseHp(num);
			},
			ai: { expose: 0.1 },
		},
		swq_yuyin: {
			audio: "saya_powei",
			trigger: { global: "phaseEnd" },
			filter(event, player) {
				return event.player != player &&
					event.player.hasCard(true, 'h') &&
					get.discarded().filterInD("d").filter(card => get.type(card) == "identity").length;
			},
			persevereSkill: true,
			frequent: true,
			async content(event, trigger, player) {
				await trigger.player.addTempSkill("swq_yuyin_view")
				const result = await player
					.chooseButton(["御因：是否视为使用其中一张牌？", trigger.player.getCards('h').map(card => {
						if(get.name(card) != card.name) ui.create.cardTempName(card);
						return card;
					})])
					.set("filterButton", button => {
						var player = _status.event.player;
						var card = button.link;
						var cardx = get.autoViewAs({ name: get.name(card, get.owner(card)), nature: get.nature(card, get.owner(card)), isCard: true }, "unsure");
						return player.hasUseTarget(cardx, true, false);
					})
					.set("ai", button => {
						var card = button.link;
						return _status.event.player.getUseValue(get.name(card, get.owner(card)));
					})
					.forResult();
				if (result?.bool) {
					const card = result.links[0];
					const cardx = get.autoViewAs({ name: get.name(card, get.owner(card)), nature: get.nature(card, get.owner(card)), isCard: true }, "unsure");
					await trigger.player.removeSkill("swq_yuyin_view")
					await trigger.player.showCards(card, get.translation(trigger.player) + '的【御因】牌展示');
					await game.delayx();
					const res2 = await player.chooseUseTarget(cardx, true)
						.forResult();
					if(res2?.bool && res2?.targets?.length) {
						const target = res2.targets[0];
						if(trigger.player === target) await target.draw();
					}
				}
				else await trigger.player.removeSkill("swq_yuyin_view");
			},
			subSkill: {
				view: {
					charlotte: true,
					onremove: true,
					nopop: true,
					mod: {
						cardname(card, player) {
							if (get.type(card, "trick", false) == "identity") {
								switch(card?.name.replace(/^swq_wudu_/, "")) {
									case "zhu":
										return "tuixinzhifu";
									case "zhong":
										return "wuzhong";
									case "fan":
										return "qizhengxiangsheng";
									case "nei":
										return "wanjian";
									default:
										return "tiesuo";
								}
							}
						},
					},
				},
			},
			ai: {
				combo: "swq_wudu",
				threaten: 1.2,
				result: {
					player: 1,
				},
			}
		},

		//异构奇英录
		// 异构沮授
		swyg_jianying: {
			audio: 'xinjianying',
			trigger: { player: "useCard" },
			frequent: true,
			filter(event, player) {
				const evt = player.getLastUsed(1);
				if (!evt || !evt.card) return false;
				if (!player.isPhaseUsing()) return false;
				const evt2 = evt.getParent("phaseUse");
				if (!evt2 || evt2.name != "phaseUse" || evt2 !== event.getParent("phaseUse")) return false;
				if (!get.cardNameLength(evt.card)) return
				return true
			},
			init(player) {
				if (player.isPhaseUsing()) {
					const evt = _status.event.getParent("phaseUse");
					const history = player.getHistory("useCard", evt2 => evt2.getParent("phaseUse") == evt);
					if (history.length) {
						const trigger = history[history.length - 1];
						if (get.cardNameLength(trigger.card)) return;
						player.storage.swyg_jianying_mark = trigger.card;
						player.markSkill("swyg_jianying_mark");
						game.broadcastAll(
							(player, cardNameLength) => {
								if (player.marks.swyg_jianying_mark) player.marks.swyg_jianying_mark.firstChild.innerHTML = get.translation(cardNameLength);
							},
							player,
							get.cardNameLength(trigger.card)
						);
						player.when("phaseUseAfter").then(() => {
							player.unmarkSkill("swyg_jianying_mark");
							delete player.storage.swyg_jianying_mark;
						});
					}
				}
			},
			onremove(player) {
				player.unmarkSkill("swyg_jianying_mark");
				delete player.storage.swyg_jianying_mark;
			},
			async content(event, trigger, player) {
				const evt = player.getLastUsed(1);
				const evenCardnum = get.cardNameLength(trigger.card)
				const lastCardnum = get.cardNameLength(evt.card)
				if (evenCardnum === lastCardnum) {
					await player.draw()
				}
				else if (Math.abs(evenCardnum - lastCardnum) === 1 && !player.hasSkill("swyg_jianying_effect")) {
					player.addTempSkill("swyg_jianying_effect", { player: "useCard1", global: ["phaseAfter", "phaseBeforeStart"] })
				}
				else if (Math.abs(evenCardnum - lastCardnum) > 1) {
					delete player.getStat("skill")['swyg_quanlue']
				}
			},
			mod: {
				aiOrder(player, card, num) {
					if (typeof card == "object" && player.isPhaseUsing()) {
						const evt = player.getLastUsed();
						if (!evt || !evt.card || evt.getParent("phaseUse") !== _status.event.getParent("phaseUse")) return num;
						if ((get.cardNameLength(evt.card) && get.cardNameLength(evt.card) == get.cardNameLength(card))) {
							return num + 10;
						}
					}
				},
				cardUsable(card, player) {
					if (player.isPhaseUsing() && typeof card == "object") {
						const evt = player.getLastUsed();
						if (evt && evt.card && evt.getParent("phaseUse") === _status.event.getParent("phaseUse")) {
							const cardLength = get.cardNameLength(card)
							const evtCardLength = get.cardNameLength(evt.card)
							const abs = Math.abs(evtCardLength - cardLength)
							if (abs === 1) return Infinity
						}
					}
				},
				targetInRange(card, player) {
					if (player.isPhaseUsing() && typeof card == "object") {
						const evt = player.getLastUsed();
						if (evt && evt.card && evt.getParent("phaseUse") === _status.event.getParent("phaseUse")) {
							const cardLength = get.cardNameLength(card)
							const evtCardLength = get.cardNameLength(evt.card)
							const abs = Math.abs(evtCardLength - cardLength)
							if (abs === 1) return true
						}
					}
				},
			},
			group: ["swyg_jianying_mark", "swyg_jianying_clear"],
			subSkill: {
				mark: {
					charlotte: true,
					trigger: { player: "useCard1" },
					filter(event, player) {
						return player.isPhaseUsing();
					},
					forced: true,
					popup: false,
					firstDo: true,
					async content(event, trigger, player) {
						if (!get.cardNameLength(trigger.card)) player.unmarkSkill("swyg_jianying_mark");
						else {
							player.storage.swyg_jianying_mark = trigger.card;
							player.addTip("swyg_jianying", "渐营 " + get.translation(get.name(trigger.card, player)) + get.cardNameLength(trigger.card, player), true);
							player.markSkill("swyg_jianying_mark");
							game.broadcastAll(
								(player, cardNameLength) => {
									if (player.marks.swyg_jianying_mark) player.marks.swyg_jianying_mark.firstChild.innerHTML = get.translation(cardNameLength);
								},
								player,
								get.cardNameLength(trigger.card, player)
							);
						}
					},
					intro: {
						markcount(card, player) {
							return parseFloat(get.cardNameLength(card));
						},
						content(card, player) {
							return `<li>上一张使用的牌名字<br>${get.translation(get.name(card, player))}</li>`;
						},
					},
				},
				clear: {
					charlotte: true,
					trigger: { player: "phaseUseAfter" },
					filter(event, player) {
						return player.storage.swyg_jianying_mark;
					},
					forced: true,
					popup: false,
					firstDo: true,
					async content(event, trigger, player) {
						player.unmarkSkill("swyg_jianying_mark");
						delete player.storage.swyg_jianying_mark;
					},
				},
				effect: {
					mod: {
						cardUsable: () => Infinity,
						targetInRange: () => true,
					},
					mark: true,
					marktext: "渐营",
					intro: {
						content: "使用下一张牌无距离和次数限制",
					},
				},
			},
		},
		swyg_quanlue: {
			audio: 'dcjianying',
			enable: "phaseUse",
			usable: 1,
			selectCard: 1,
			position: 'he',
			filterCard: () => true,
			filter: (event, player) => player.hasCard(true, "he"),
			// prompt:'弃置一张牌然后从牌堆中获得一张任意点数的牌',
			async content(event, trigger, player) {
				let numbers = []
				ui.cardPile.childNodes.forEach(name => numbers.add(String(get.cardNameLength(name))))
				numbers = numbers.sort((a, b) => a - b)
				const { result } = await player.chooseControl(...numbers).set('prompt', '从牌堆中获得一张任意点数的牌')
				if (result.control) {
					const card = get.cardPile2(card => get.cardNameLength(card) == result.control);
					if (card) {
						await player.gain(card, 'gain2')
					} else {
						game.log(`牌堆没有${result.control}个字的牌`)
					}
				}
			},
			ai: {
				order: 2,
			},
		},
		swyg_shibei: {
			audio: "dcshibei",
			inherit: 'shibei',
			filter(trigger, player) {
				const damage = player.getHistory("damage")
				const index = damage.indexOf(trigger)
				return index === 1 || index === 0
			},
			async content(event, trigger, player) {
				const damage = player.getHistory("damage")
				if (damage.indexOf(trigger) === 0) {
					await player.recover();
				} else if (damage.indexOf(trigger) === 1) {
					await player.loseHp();
					await player.draw()
				}
			}
		},
		// 异构郭嘉
		swyg_shisheng: {
			audio: "xianmou",
			enable: "phaseUse",
			usable: 1,
			selectTarget: 1,
			filterTarget: lib.filter.notMe,
			selectCard: -1,
			ai2(target) {
				const player = get.player();
				const [cards1, cards2, hp1, hp2, eq1, eq2] = [
					player.countCards('h'), target.countCards('h'),
					player.hp, target.hp,
					player.countCards('e'), target.countCards('e')
				]
				return (cards1 > cards2) + (hp1 > hp2) + (eq1 > eq2);
			},
			async content(event, trigger, player) {
				const { target } = event
				const [cards1, cards2, hp1, hp2, eq1, eq2] = [
					player.countCards('h'), target.countCards('h'),
					player.hp, target.hp,
					player.countCards('e'), target.countCards('e')
				]
				let num = (cards1 > cards2) + (hp1 > hp2) + (eq1 > eq2)
				player.popup(`${num}项`, "wood")
				game.log(`#b${get.translation(player)}`,'与',`#b${get.translation(target)}`,'比较', `#y胜${num}项`);
				await game.delayx()
				await player.addAdditionalSkills("swyg_shisheng", []);
				if(num >= 1) {
					await player.addAdditionalSkills("swyg_shisheng", "tiandu");
				}
				if(num >= 2) {
					await  player.draw(2)
				}
				if(num >= 3){
					await player.recover()
				}
			},
			ai: {
				order: 7,
				threaten: 1.2,
				result: {
					player: function(player, target) { // TODO：好像没用？
						return get.max(game.filterPlayer(), tar => {
							const [cards1, cards2, hp1, hp2, eq1, eq2] = [
								player.countCards('h'), tar.countCards('h'),
								player.hp, tar.hp,
								player.countCards('e'), tar.countCards('e')
							]
							return (cards1 > cards2) + (hp1 > hp2) + (eq1 > eq2);
						}) * 1.5
					},
				},
			},
		},
		swyg_shibai: {
			audio: "lunshi",
			trigger: { player: 'damageEnd' },
			async cost(event, trigger, player) {
				const list = ['re_guojia', 'ol_xunyu', 're_simayi', 're_caocao', 'xizhicai']
				const skills = ['new_reyiji', 'oljieming', 'refankui', 'new_rejianxiong', 'chouce', 'cancel']
				if (!trigger.source) {
					skills.remove('refankui')
					list.remove('re_simayi')
				}
				const { result } = await player
					.chooseControl(skills)
					.set("ai", (event) => {
						const player = get.player();
						const priority = {
							//一张牌按6价值算。TODO：应该可以计算当前event下技能的使用价值
							new_reyiji: () => {
								return 6 * 2;
							},
							oljieming: () => {
								return get.max(game.filterPlayer(), (p) => {
									//let att = get.attitude(player, target);
									let draw = Math.min(5, p.maxHp) - p.countCards("h");
									return Math.abs(draw) * 3.8
								})
							},
							refankui: () => {
								return (Math.random() + 1.1) * 6
							},
							new_rejianxiong: () => {
								return (event?.getTrigger()?.cards?.reduce((acc, card) => acc + get.value(card, player), 0) || 0) + 6 * 1
							},
							chouce: () => {
								return (Math.random() + 1.1) * 6;
							},
						};
						const entries = Object.entries(priority).map(([key, fn]) => [key, fn()]);
						entries.sort((a, b) => b[1] - a[1]);
						return entries[0][0] || 0;
					})
					.set("dialog", [`十败：` + "请选择尝试发动的技能", [list, "character"]])
				event.result = {
					bool: result.control !== 'cancel',
					cost_data: result.control
				}
			},
			async content(event, trigger, player) {
				const skill = event.cost_data
				player.addTempSkill(skill)
				player.markAuto("swyg_shibai", skill)
			},
			group: ["swyg_shibai_check", "swyg_shibai_check2"],
			subSkill: {
				check: {
					charlotte: true,
					trigger: { player: "damageEnd" },
					filter(event, player) {
						return player.getStorage("swyg_shibai").length
					},
					direct: true,
					lastDo: true,
					priority: -Infinity,
					async content(event, trigger, player) {
						player.getStorage("swyg_shibai").forEach((sk) => player.removeSkill(sk))
						player.setStorage("swyg_shibai", [])
					},
				},
				check2: {
					charlotte: true,
					trigger: { player: ["useSkill", "logSkillBegin"] },
					filter(event, player) {
						var info = get.info(event.skill);
						if (info && info.charlotte) return false;
						var skill = get.sourceSkillFor(event);
						return player.getStorage("swyg_shibai").includes(skill);
					},
					direct: true,
					firstDo: true,
					priority: Infinity,
					async content(event, trigger, player) {
						const skill = get.sourceSkillFor(trigger);
						player.removeSkill(skill);
						player.unmarkAuto("swyg_shibai", [skill])
					},
				}
			},
			ai: {
				maixie: true,
				maixie_hp: true,
				effect: {
					target(card, player, target) {
						if (get.tag(card, "damage")) {
							if (player.hasSkillTag("jueqing", false, target)) return [1, -2];
							if (!target.hasFriend()) return;
							let num = 1;
							if (get.attitude(player, target) > 0) {
								if (player.needsToDiscard()) num = 0.7;
								else num = 0.5;
							}
							if (!target.isDamaged()) num = num * 2;
							if (target.hp >= 4) return [1, num * 2];
							if (target.hp == 3) return [1, num * 1.5];
							if (target.hp == 2) return [1, num * 0.5];
						}
					},
				},
				threaten: 0.6,
			},
		},
		// 异构荀彧
		swyg_zaifu: {
			audio: "sbjieming",
			trigger: {
				player: "damageEnd",
			},
			async cost(event, trigger, player) {
				event.result = await player
					.chooseTarget(get.prompt2("swyg_zaifu"), `令一名角色将手牌调整至体力上限（至多摸五张）`)
					.set("ai", target => {
						const player = get.player();
						let att = get.attitude(player, target);
						let draw = Math.min(5, target.maxHp) - target.countCards("h");
						if (draw >= 0) {
							if (target.hasSkillTag("nogain")) att /= 6;
							if (att > 2) {
								return Math.sqrt(draw + 1) * att;
							}
							return att / 3;
						}
						if (draw < -1) {
							if (target.hasSkillTag("nogain")) att *= 6;
							if (att < -2) {
								return -Math.sqrt(1 - draw) * att;
							}
						}
						return 0;
					})
					.forResult();
			},
			async content(event, trigger, player) {
				const target = event.targets[0];
				const num = target.maxHp - target.countCards("h");
				if (num > 0) {
					await target.draw(Math.min(5, num)).gaintag.add("swyg_zaifu");
				}
				else if (num < 0 && target.countDiscardableCards(target, "h") > 0) {
					const result = await target.chooseToDiscard(-num, "h", true).forResult();
					if(result?.cards && result?.cards.length && target.isIn() && target.getHp() > 0) {
						//await player.directgains(result?.cards, null, 'swyg_zaifu2');
						if (_status.connectMode) game.broadcastAll(() => (_status.noclearcountdown = true));
						let cards = game.cardsGotoOrdering(result.cards).cards;
						let given_map = {};
						let giveNum = target.getHp();
						while (cards.length && giveNum > 0) {
							let result;
							if (cards.length == 1) result = { bool: true, links: cards.slice() };
							else {
								result = await player.chooseCardButton("宰辅：请选择要分配的牌", false, cards, [1, Math.min(cards.length, giveNum)]).set("ai", function (button) {
									if (!ui.selected.buttons.length) return get.buttonValue(button);
									return 0;
								}).forResult();
							}
							if(!result?.bool || !result?.links) break;
							const gives = result.links;
							const result2 = await player
								.chooseTarget("宰辅：选择获得" + get.translation(gives) + "的角色", false)
								.set("ai", target => {
									return get.attitude(get.event("player"), target) * get.sgn(get.sgn(get.event("goon")) + 0.5);
								})
								.set(
									"goon",
									gives.reduce((sum, card) => sum + get.value(card), 0)
								).forResult();
							if (result2?.bool) {
								giveNum -= gives.length
								cards.removeArray(gives);
								const id = result2.targets[0].playerid;
								if (!given_map[id]) given_map[id] = [];
								given_map[id].addArray(gives);
							}
						}
						if (_status.connectMode) game.broadcastAll(() => delete _status.noclearcountdown);
						let list = [];
						for (const i in given_map) {
							const source = (_status.connectMode ? lib.playerOL : game.playerMap)[i];
							player.line(source, "green");
							game.log(source, "获得了", given_map[i]);
							list.push([source, given_map[i]]);
						}
						await game
							.loseAsync({
								gain_list: list,
								giver: player,
								animate: "gain2",
							})
							.setContent("gaincardMultiple");
						await game.delayx();
					}
				}
			},
			ai: {
				maixie: true,
				maixie_hp: true,
				effect: {
					target(card, player, target, current) {
						if (get.tag(card, "damage") && target.hp > 1) {
							if (player.hasSkillTag("jueqing", false, target)) return [1, -2];
							var max = 0;
							var players = game.filterPlayer();
							for (var i = 0; i < players.length; i++) {
								if (get.attitude(target, players[i]) > 0) {
									max = Math.max(Math.min(5, players[i].hp) - players[i].countCards("h"), max);
								}
							}
							switch (max) {
								case 0:
									return 2;
								case 1:
									return 1.5;
								case 2:
									return [1, 2];
								default:
									return [0, max];
							}
						}
						if ((card.name == "tao" || card.name == "caoyao") && target.hp > 1 && target.countCards("h") <= target.hp) return [0, 0];
					},
				},
				threaten: 0.7,
			},
			group: "swyg_zaifu_tag",
			subSkill: {
				tag: {
					trigger: { global: "phaseEnd" },
					filter(event, player) {
						return game.filterPlayer().some(target => {
							return target.hasHistory("lose", function (evt) {
								for (var i in evt.gaintag_map) {
									if (evt.gaintag_map[i].includes("swyg_zaifu")) return true;
								}
							})
						})
					},
					async cost(event, trigger, player) {
						event.result = await player
							.chooseTarget(
								`宰辅：选择角色A和B，视为A对B使用一张随机的伤害类锦囊牌`,
								false,
								2
							)
							.set("ai", target => {
								const player = get.player();
								if(ui?.selected?.targets?.length == 1) {
									return -get.attitude(player, target);
								}
								return Math.random() + get.attitude(player, target) > 0 ? 0 : 0.3;
							})
							.forResult();
					},
					async content(event, trigger, player) {
						const targets = event.targets;
						const list = get.inpileVCardList(info => {
							return info[0] == "trick" && get.tag({ name: info[2] }, "damage");
						});
						await targets[0].useCard(get.autoViewAs({ name: list.randomGet()[2], isCard: true}), targets[1], false);
					}
				},
			},
		},
		swyg_dingce: {
			audio: "dinghan",
			onremove: true,
			intro: { content: "已记录牌名：$" },
			enable: ["chooseToUse", "chooseToRespond"],
			filter(event, player) {
				for (let i = 0; i < lib.inpile.length; i++) {
					const name = lib.inpile[i];
					if (player.getStorage("swyg_dingce").includes(name)) continue
					if (name == "sha") {
						if (event.filterCard(get.autoViewAs({ name }, "unsure"), player, event)) return true;
						for (var nature of lib.inpile_nature) {
							if (event.filterCard(get.autoViewAs({ name, nature }, "unsure"), player, event)) return true;
						}
					}
					else if (get.type(name) == "trick" && event.filterCard(get.autoViewAs({ name }, "unsure"), player, event)) return true;
					else if (get.type(name) == "basic" && event.filterCard(get.autoViewAs({ name }, "unsure"), player, event)) return true;
				}
				return false;
			},
			chooseButton: {
				dialog(event, player) {
					const list = [];
					for (let i = 0; i < lib.inpile.length; i++) {
						const name = lib.inpile[i];
						if (player.getStorage("swyg_dingce").includes(name)) continue
						if (name == "sha") {
							if (event.filterCard(get.autoViewAs({ name }, "unsure"), player, event)) list.push(["基本", "", "sha"]);
							for (var nature of lib.inpile_nature) {
								if (event.filterCard(get.autoViewAs({ name, nature }, "unsure"), player, event)) list.push(["基本", "", "sha", nature]);
							}
						}
						else if (get.type(name) == "trick" && event.filterCard(get.autoViewAs({ name }, "unsure"), player, event)) list.push(["锦囊", "", name]);
						else if (get.type(name) == "basic" && event.filterCard(get.autoViewAs({ name }, "unsure"), player, event)) list.push(["基本", "", name]);
					}
					return ui.create.dialog("定策", [list, "vcard"]);
				},
				check(button) {
					if (_status.event.getParent().type != "phase") return 1;
					var player = _status.event.player;
					if (["wugu", "zhulu_card", "yiyi", "lulitongxin", "lianjunshengyan", "diaohulishan"].includes(button.link[2])) return 0;
					return player.getUseValue({
						name: button.link[2],
						nature: button.link[3],
					});
				},
				backup(links, player) {
					return {
						filterCard(card) {
							return get.cardNameLength(card) === get.cardNameLength(links[0][2])
						},
						popname: true,
						check(card) {
							return 8 - get.value(card);
						},
						position: "hse",
						viewAs: { name: links[0][2], nature: links[0][3] },
						async precontent(event, unkown, player) {
							player.markAuto("swyg_dingce", [links[0][2]]);
							player.logSkill(event.name);
						},
					};
				},
				prompt(links, player) {
					return `将一张牌名字数为${get.cardNameLength(links[0][2])}的牌当做` + (get.translation(links[0][3]) || "") + get.translation(links[0][2]) + "使用";
				},
			},
			hiddenCard(player, name) {
				if (!lib.inpile.includes(name)) return false;
				return !player.getStorage("swyg_dingce").includes(name)
			},
			group: "swyg_dingce_remove",
			subSkill: {
				remove: {
					trigger: { player: "phaseBegin" },
					direct: true,
					filter(event, player) {
						return player.getStorage("swyg_dingce").length
					},
					async content(event, trigger, player) {
						let dialog = [get.prompt("swyg_dingce")]
						let list = player.getStorage("swyg_dingce")
						if (list.length) {
							dialog.push('<div class="text center">已记录</div>');
							dialog.push([list, "vcard"]);
						}
						const { result } = await player.chooseButton(dialog).set("ai", function (button) {
							var player = get.player()
							return player.getUseValue({
								name: button.link[2],
							})
						});
						if (result.bool) {
							player.logSkill("swyg_dingce");
							var name = result.links[0][2];
							if (player.getStorage("swyg_dingce").includes(name)) {
								player.unmarkAuto("swyg_dingce", [name]);
								game.log(player, "从定策记录中移除了", "#y" + get.translation(name));
							}
							game.delayx();
						}
					},
				},
				backup: {},
			},
			ai: {
				respondSha: true,
				respondShan: true,
				respondTao: true,
				save: true,
				skillTagFilter(player, tag, arg) {
					switch (tag) {
						case "save":
							return !player.getStorage("swyg_dingce").includes("tao") || !player.getStorage("swyg_dingce").includes("jiu")
						case "respondTao":
							return !player.getStorage("swyg_dingce").includes("tao")
						case "respondShan":
							return !player.getStorage("swyg_dingce").includes("shan")
						case "respondSha":
							return !player.getStorage("swyg_dingce").includes("sha")
					}
				},
				order: 5,
				result: {
					player: 1
				},
			}
		},
		// 异构曹金玉
		swyg_yuqi: {
			audio: 'yuqi',
			trigger: { player: 'damageEnd' },
			async cost(event, trigger, player) {
				event.result = await player.chooseTarget('选择要弃置的角色', [1, player.getHp()], (card, player, target) => {
					return !target.hasHistory('damage') && target.countCards('h') > 0
				}).set('ai', target => {
					const att = get.attitude(player, target)
					if (att < 0) return 1000 - target.countCards('h')
					return target.countCards('h') - 8
				}).forResult()
			},
			async content(event, trigger, player) {
				const targets = event.targets.sortBySeat()
				const yu = []
				const shatao = []
				for await (const target of targets) {
					if (target.countCards('h') > 0) {
						const { result } = await player.discardPlayerCard(target, "h", true)
						result.cards.forEach(card => {
							const name = get.name(card)
							if (name === 'tao' || name === 'sha') {
								shatao.push(card)
							} else {
								yu.push(card)
							}
						})
					}
				}
				while (shatao.length > 0 && player.getStorage("swyg_yuqi").length < 2) {
					const { result } = await player.chooseButton(["隅泣：是否使用其中的一张牌？", shatao])
						.set("filterButton", button => {
							const player = _status.event.player
							return !player.getStorage("swyg_yuqi").includes(get.name(button.link)) && player.hasUseTarget(button.link);
						})
						.set("ai", button => {
							const player = _status.event.player,
								card = button.link,
								cards = _status.event.getParent().cards;
							const val = player.getUseValue(card) + 0.01;
							if ((val > 0 && cards.length > 1) || (val > 4 && cards.length == 1 && (player.maxHp > 3 || player.isDamaged()))) return get.order(card) + val / 5;
							return 0;
						});
					if (result?.bool) {
						const card = result.links[0];
						player.$gain2(card, false);
						game.delayx();
						await player.chooseUseTarget(true, card, false);
						shatao.remove(card)
						player.markAuto("swyg_yuqi", [get.name(card)])
					}
					else {
						break
					}
				}
				yu.addArray(shatao)
				player.addToExpansion(yu, player, "give").gaintag.add("swyg_yuqi");
			},
			marktext: "隅",
			intro: {
				content: "expansion",
				markcount: "expansion",
			},
			onremove: true,
			group: ["swyg_yuqi_clear"],
			subSkill: {
				clear: {
					trigger: { global: 'phaseEnd' },
					charlotte: true,
					direct: true,
					filter(event, player) {
						return player.hasHistory("useSkill", evt => evt.skill == "swyg_yuqi");
					},
					async content(event, trigger, player) {
						player.setStorage("swyg_yuqi", [])
					}
				}
			},
			ai: {
				maixie: true,
				maixie_hp: true,
				threaten: 0.8,
				expose: 0.3,
				effect: {
					target(card, player, target) {
						if (get.tag(card, "damage")) {
							if (player.hasSkillTag("jueqing", false, target)) return [1, -2];
							if (!target.hasFriend()) return;
							let num = 1;
							if (target.hp >= 4) return [1, num * 2];
							if (target.hp == 3) return [1, num * 1.2];
							if (target.hp == 2) return [1, num * 0.5];
						}
					},
				},
			},
		},
		swyg_shanshen: {
			audio: 'shanshen',
			trigger: { player: 'phaseZhunbeiBegin' },
			filter(event, player) {
				return player.getExpansions("swyg_yuqi").length > 0 && player.countCards("he") > 0;
			},
			async cost(event, trigger, player) {
				const expansions = player.getExpansions("swyg_yuqi");
				const cards = player.getCards('he')
				const num = Math.max(1, player.getDamagedHp())
				const max = Math.min(expansions.length, cards.length, num)
				const { result, moved } = await player.chooseToMove("善身：交换至多" + get.cnNumber(max) + "张牌")
					.set("list", [
						["你的「隅泣」", expansions, "swyg_shanshen_tag"],
						["你的手牌", cards],
					])
					.set("filterMove", (from, to, moved) => {
						if (moved[0].includes(from.link)) {
							if (typeof to == "number") {
								if (to == 1) {
									if (moved[1].length >= _status.event.max) return false;
								}
								return true;
							}
						}
						return true;
					})
					.set("max", max)
					.set("processAI", function (list) {
						if (_status.event.max) {
							let gain = list[0][1]
									.sort((a, b) => {
										return player.getUseValue(b, null, true) - player.getUseValue(a, null, true);
									})
									.slice(0, _status.event.max),
								give = list[1][1]
									.sort((a, b) => {
										return get.value(a, player) - get.value(b, player);
									})
									.slice(0, _status.event.max);
							for (let i of gain) {
								if (get.value(i, player) < get.value(give[0], player)) continue;
								let j = give.shift();
								list[0][1].remove(i);
								list[0][1].push(j);
								list[1][1].remove(j);
								list[1][1].push(i);
								if (!give.length) break;
							}
						}
						return [list[0][1], list[1][1]];
					})
				const top = expansions.filter(card => !moved[0].includes(card))
				const bottom = cards.filter(card => !moved[1].includes(card))
				event.result = {
					cost_data: { top, bottom },
					bool: result.bool
				}
			},
			async content(event, trigger, player) {
				const { top, bottom } = event.cost_data
				player.addToExpansion(bottom, "give", player).gaintag.add("swyg_yuqi");
				await player.gain(top, "gain2")
				const { damage, another } = player.getExpansions("swyg_yuqi").reduce((now, card) => {
					const add = get.tag(card, "damage") ? 'damage' : 'another'
					now[add]++
					return now
				}, { damage: 0, another: 0 })
				if (damage > another) {
					player.popup("大于", "wood")
					player.addTempSkill('swyg_shanshen_gt')
				}
				else if (damage === another) {
					player.popup("等于")
					await player.draw(2)
					player.addTempSkill('swyg_shanshen_eq')
				}
				else if (damage < another) {
					player.popup("小于", "fire")
					await player.recover()
					player.addTempSkill('swyg_shanshen_lt')
				}
				await game.delayx()
			},
			subSkill: {
				gt: {
					forced: true,
					charlotte: true,
					mod: {
						cardUsable(card, player, num) {
							if (get.name(card, player) === 'sha') return num + 1
						}
					},
					trigger: { player: 'useCard' },
					filter(trigger, player) {
						return get.name(trigger.card, player) === 'sha'
					},
					async content(event, trigger, player) {
						if (player.getHistory('useCard', evt => get.name(evt.card) === 'sha').length === 1) {
							trigger.directHit.addArray(game.players)
						}
					}
				},
				eq: {
					trigger: { player: 'phaseDiscardBefore' },
					charlotte: true,
					forced: true,
					popup: false,
					async content(event, trigger, player) {
						trigger.cancel()
					}
				},
				lt: {
					mod: {
						playerEnabled(card, player, target) {
							if (target !== player) return false;
						},
					}
				}
			},
			ai: {
				combo: "swyg_yuqi",
			},
		},
		swyg_xianjing: {
			trigger: { player: 'swyg_yuqiAfter' },
			audio: 'xianjing',
			forced: true,
			juexingji: true,
			skillAnimation: true,
			animationColor: "gray",
			filter(trigger, player) {
				return !player.storage.swyg_xianjingAwake && player.getExpansions("swyg_yuqi").length >= 7
			},
			async content(event, trigger, player) {
				player.awakenSkill('swyg_xianjing')
				player.storage.swyg_xianjingAwake = true
				await player.gainMaxHp()
				await player.recover()

				const result = await player.chooseCardButton("你可以弃置任意张「隅泣」并摸等量的牌", [1, Infinity], player.getExpansions("swyg_yuqi"))
					.set('ai', (button) => {
						return true;
					})
					.forResult();
				if(result.bool) {
					await player.loseToDiscardpile(result?.links);
					await player.draw(result?.links?.length)
				}
			},
			ai: {
				combo: "swyg_yuqi",
			},
		},
		// 异构汉末献帝
		swyg_modi: {
			audio: "tianming",
			trigger: { global: 'phaseBeginStart' },
			forced: true,
			locked: true,
			filter(trigger, player) {
				return trigger.player !== player
			},
			async content(event, trigger, player) {
				const target = trigger.player
				const { result } = await target.chooseCard(`将一张牌交给${get.translation(player)}，否则你须选择对其他角色出【杀】或失去1点体力`, 1, 'he')
					.set("sourcex", player)
					.set("ai", card => {
						const player = get.player()
						const target = _status.event.sourcex
						if(get.attitude(player, target) < 0) {
							if(player.hasCard("sha", "h")) return false;
							return player.getHp() <= 1;
						}
						return true;
					})
				if (result.bool || (result.cards && result.cards.length > 0)) {
					await target.give(result.cards, player, 'giveAuto', 'bySelf')
					await player.draw()
					const { result: huan } = await player.chooseCard(`将一张牌交给${get.translation(target)}`, 1, true, 'he')
					await player.give(huan.cards, target, 'giveAuto', 'bySelf')
				}
				else {
					const { result } = await target.chooseToUse(function (card) {
						if (get.name(card) !== "sha") return false;
						return lib.filter.filterCard.apply(this, arguments);
					}, `对除${get.translation(player)}外的其他角色使用一张【杀】或失去1点体力`)
						.set("targetRequired", true)
						.set("complexSelect", true)
						.set("filterTarget", function (card, player, target) {
							if (target === _status.event.sourcex) return false;
							return lib.filter.filterTarget.apply(this, arguments);
						})
						.set("sourcex", player);
					if (!result?.bool) {
						await target.loseHp()
					}
				}
			},
		},
		swyg_zhaoling: {
			audio: "mizhao",
			marktext: '汉',
			intro: {
				name: "汉业",
				content: "mark",
			},
			enable: "phaseUse",
			usable: 3,
			selectCard: [1, Infinity],
			selectTarget: 1,
			position: 'he',
			discard: false,
			lose: false,
			delay: false,
			filterTarget: lib.filter.notMe,
			filterCard: () => true,
			ai1(card) {
				return 7 - get.value(card);
			},
			ai2(target) {
				const player = get.player();
				return get.attitude(player, target) >= 0
			},
			async content(event, trigger, player) {
				const { target, cards } = event
				await player.give(cards, target).gaintag.add("swyg_zhaoling_tag");
			},
			check(card) {
				if (ui.selected.cards.length && ui.selected.cards[0].name == "du") return 0;
				if (!ui.selected.cards.length && card.name == "du") return 20;
				const player = get.owner(card);
				if (ui.selected.cards.length >= Math.max(1, player.countCards("h") - player.hp)) return 0;
				return 10 - get.value(card);
			},
			group: 'swyg_zhaoling_use',
			subSkill: {
				use: {
					forced: true,
					trigger: { global: ["useCardAfter", "respondAfter"] },
					filter(event, player) {
						return event.player.hasHistory("lose", evt => {
							if (event !== evt.getParent()) return false;
							for (const i in evt.gaintag_map) {
								if (evt.gaintag_map[i].includes("swyg_zhaoling_tag")) return true;
							}
						});
					},
					async content(event, trigger, player) {
						await player.draw()
						player.addMark('swyg_zhaoling', 1)
					}
				}
			},
			ai: {
				order: 7,
				expose: 0.3,
				result: {
					player: 1,
				},
			}
		},
		swyg_fuhan: {
			audio: "dcsbtiancheng",
			trigger: { player: 'phaseZhunbeiBegin' },
			forced: true,
			juexingji: true,
			skillAnimation: true,
			animationColor: "metal",
			derivation: "swyg_tianzi",
			filter(event, player) {
				if (player.storage.swyg_fuhanAwake) return false
				return player.countMark("swyg_zhaoling") >= game.countGroup();
			},
			async content(event, trigger, player) {
				player.awakenSkill("swyg_fuhan");
				player.storage.swyg_fuhanAwake = true
				await player.gainMaxHp(3)
				await player.recover()
				await player.removeSkills('swyg_modi')
				await player.addSkills('swyg_tianzi')
			},
			ai: {
				combo: "swyg_zhaoling",
			}
		},
		swyg_tianzi: {
			audio: "dcsbchensheng",
			mod: {
				targetInRange(card, player, target, now) {
					return true;
				},
			},
			direct: true,
			trigger: { player: ['phaseDrawBegin2', 'phaseDiscardBegin'] },
			filter: function (event, player) {
				if(event.name == "phaseDraw") return !event.numFixed;
				return true
			},
			async content(event, trigger, player) {
				const name = event.triggername
				if (name === 'phaseDrawBegin2') {
					trigger.num += Math.min(3, player.getHp())
					player.logSkill("swyg_tianzi")
				}
				else if (name === 'phaseDiscardBegin') {
					trigger.cancel()
				}
			},
			ai: {
				threaten: 1.2,
			},
		},
		swyg_handi: {
			unique: true,
			zhuSkill: true,
			firstDo: true,
			trigger: { global: ["useCardAfter", "respondAfter"] },
			usable: 1,
			audio: "dcsbzhanban",
			filter(event, player) {
				return event.player.hasHistory("lose", evt => {
					if (event !== evt.getParent()) return false;
					for (const i in evt.gaintag_map) {
						if (evt.gaintag_map[i].includes("swyg_zhaoling_tag")) return true;
					}
				});
			},
			async content(event, trigger, player) {
				trigger.player.addSkill('swyg_handi_buff')
				trigger.player.when("useCardAfter").then(() => {
					player.removeSkill('swyg_handi_buff')
				})
			},
			forced: true,
			subSkill: {
				buff: {
					mod: {
						targetInRange: () => true,
						cardUsable: () => Infinity,
					},
					charlotte: true,
					mark: true,
					marktext: '诏',
					intro: {
						name: '诏书',
						content: '使用的下一张牌无距离和次数限制'
					}
				}
			}
		},
		// 异构小乔
		swyg_tianxiang: {
			audio: "tianxiang_re_xiaoqiao",
			trigger: { player: "damageBegin4" },
			filter(event, player) {
				return event.num > 0 && player.countCards('h') > 0;
			},
			change(player, num) {
				if (typeof player.storage.swyg_tianxiang !== "number") player.storage.swyg_tianxiang = 0;
				if (!num) return;
				player.storage.swyg_tianxiang += num;
				player.markSkill("swyg_tianxiang");
				if(player.storage.swyg_tianxiang == 0) {
					player.unmarkSkill("swyg_tianxiang");
				}
				game.log(player, "的手牌上限", "#g" + (num > 0 ? "+" : "") + num);
			},
			async content(event, trigger, player) {
				await player.showHandcards();
				if(player.getCards('h').every(card => get.suit(card) == "heart")) {
					const result = await player
						.chooseTarget(get.prompt2("swyg_tianxiang"), "将此伤害转移给其他角色，摸两张牌并使手牌上限-1", function (card, player, target) {
							return target != player;
						})
						.set("forced", true)
						.set("ai", function (target) {
							const player = get.player();
							return get.damageEffect(target, player, player) - get.attitude(player, target);
						})
						.forResult();
					if (result?.bool && result?.targets[0]) {
						const target = result.targets[0];
						trigger.cancel();
						await player.line(target);
						await target.damage(trigger.source || "nosource", trigger.num || 0, "nocard");
						await player.draw(2);
						await lib.skill.swyg_tianxiang.change(player, -1);
					}
				}
				else if(player.countCards('h') > 0) {
					const num = Math.abs(player.getHandcardLimit() - player.getHp()) || 1;
					const result = await player.chooseCard('h', '是否重铸至多' + num + '张手牌？', [1, num]).set('ai', function (card) {
						return 10 - get.value(card) - (get.suit(card) == "heart") * 8;
					})
						.forResult();
					if (result?.bool) {
						player.recast(result?.cards);
					};
				}
			},
			markimage: "image/card/handcard.png",
			intro: {
				content(storage, player) {
					var num = player.storage.swyg_tianxiang;
					return "手牌上限" + (num >= 0 ? "+" : "") + num;
				},
			},
			group: "swyg_tianxiang_add",
			subSkill: {
				add: {
					forced: true,
					audio: "sbtianxiang",
					trigger: {
						player: "damageEnd",
					},
					async content(event, trigger, player){
						lib.skill.swyg_tianxiang.change(player, trigger.num || 0);
					},
				}
			},
			ai: {
				maixie: true,
				maixie_defend: true,
				threaten: function (player, target) {
					return player.countCards('h') == 0 ? 1.4 : 0.7;
				},
				effect: {
					target(card, player, target) {
						if (player.hasSkillTag("jueqing", false, target)) return;
						if (get.tag(card, "damage") && target.countCards("h") >= 4) return 0.9;
						if (get.tag(card, "damage") && target.countCards("h") >= 1) return 0.7;
					},
				},
			},
			mod: {
				aiValue(player, card, num) {
					if (num <= 0) return num;
					let suit = get.suit(card, player);
					if (suit === "heart") return num + 1.6;
				},
				aiUseful(player, card, num) {
					if (num <= 0) return num;
					let suit = get.suit(card, player);
					if (suit === "heart") return num + 3;
				},
			}
		},
		swyg_hongyan: {
			mod: {
				suit(card, suit) {
					const player = get.owner(card) || _status.event.player;
					const num = Math.abs(player.getHandcardLimit() - player.getHp()) || 1;
					if (num >= 1 && suit == "spade") return "heart";
					if (num >= 2 && suit == "club") return "heart";
					if (num >= 3 && suit == "diamond") return "heart";
				},
				maxHandcard(player, num) {
					return num + player.countMark("swyg_tianxiang");
				},
			},
		},

		// 二游同人创
		// 卡提希娅（❤❤❤
		swe_fengdu: {
			audio: `${ea}katixiya:2`,
			trigger: {
				player: "useCardToPlayered",
				target: "useCardToTargeted",
			},
			init: function (player, skill) {
				player.storage[skill] = 0;
			},
			usable: 1,
			filter(event, player) {
				if (!event.card || event?.targets?.length !== 1 || !event.player.isIn()) return false;
				if (!["basic", "trick"].includes(get.info(event.card).type)) return false;
				return (event.player !== player && player === event.targets[0]) || (event.player === player && player !== event.targets[0]);
			},
			async cost(event, trigger, player) {
				var list = [],
					choiceList = ["令此牌额外增加一个目标", "令此牌回复值/伤害值+1"];
				if(player.storage["swe_fengduChoice"] === "选项一") {
					choiceList[0] +=  '<span style="color: yellow;">' + "(上次选择)" + "</span>"
				}
				else if(player.storage["swe_fengduChoice"] === "选项二") {
					choiceList[1] +=  '<span style="color: yellow;">' + "(上次选择)" + "</span>"
				}
				if (game.hasPlayer(p => {
					return !trigger?.targets?.includes(p) && lib.filter.targetEnabled2(trigger.card, trigger.player, p);
				})) list.push("选项一");
				else choiceList[0] = '<span style="opacity:0.5">' + choiceList[0] + "</span>";
				list.push("选项二");
				list.push("cancel2");
				const result = await player
					.chooseControl(list)
					.set("prompt", get.prompt("swe_fengdu"))
					.set("choiceList", choiceList)
					.set("choiceList2", list)
					.set("ai", function (event, player) {
						let trigger = event.getTrigger();
						let priority1 = 1,
							priority2 = 1;
						let inc = player.hasSkill("swe_fengdu_shenquanjian") ? 1 : 2;
						if (player.storage["swe_fengduChoice"] === "选项一") {
							priority2 += inc;
						} else if (player.storage["swe_fengduChoice"] === "选项二") {
							priority1 += inc;
						}
						if(game.hasPlayer(target => {
							return trigger.targets.includes(target) &&
								lib.filter.targetEnabled2(trigger.card, trigger.player, target) &&
								get.effect(target, trigger.card, trigger.player, _status.event.player) > 0;
						})) {
							priority1 += 1;
						}
						if(player.getHp() < 3) {
							priority2 /= 3;
						}
						if(!player.hasSkill("swe_fengdu_yiquanjian")) {
							priority2 *= 1.5;
							if(player.hasSkill("swe_fengdu_renquanjian") && player.hasSkill("swe_fengdu_shenquanjian")) {
								priority2 *= 2;
							}
						}
						return Math.random() > 0.2 ? (priority1 >= priority2 ? (get.event("choiceList2").includes("选项一") ? "选项一" : "cancel2") : "选项二") : "cancel2";
					})
					.forResult();
				let targetx;
				if(result.control === "选项一") {
					targetx = await player
						.chooseTarget("为" + get.translation(trigger.card) + "增加一个目标", true, function (card, player, target) {
							var trigger = _status.event.getTrigger();
							return !trigger.targets.includes(target) && lib.filter.targetEnabled2(trigger.card, trigger.player, target);
						})
						.set("ai", function (target) {
							var trigger = _status.event.getTrigger();
							return get.effect(target, trigger.card, trigger.player, _status.event.player);
						}).
						forResultTargets();
				}
				event.result = {
					bool: result.control && result.control !== "cancel2",
					cost_data: result.control,
					targets: targetx || [],
				};
			},
			async content(event, trigger, player) {
				switch(event.cost_data) {
					case "选项一":
						const target = event.targets[0];
						trigger.targets.push(target);
						trigger.player.line(target);
						game.log(player, "为", "#y" + get.translation(trigger.card), "增加了", target, "为目标");
						await game.delayx();
						break;
					case "选项二":
						const evt = trigger.getParent();
						if(evt) {
							if (!evt.baseDamage) evt.baseDamage = 1;
							evt.baseDamage += 1;
							game.log(evt.card, "的伤害值/回复值", "#y+" + 1);
						}
						break;
					default:
						break;
				}
				if(player.storage["swe_fengduChoice"] && player.storage["swe_fengduChoice"] !== event.cost_data) {
					await player.draw();
					if(!player.hasSkill("swe_fengdu_shenquanjian")) {
						await player.addSkill("swe_fengdu_shenquanjian");
						await player.popup("神权剑");
						await game.delayx();
					}
				}
				player.storage["swe_fengduChoice"] = event.cost_data;
			},
			group: "swe_fengdu_damage",
			createSword(player, name) {
				if(!_status.swJianCSS) {
					_status.swJianCSS = true
					const style = document.createElement('style')
					style.innerHTML = `
						@keyframes swordAnim1 {
						  0% { transform: translate(0, -12px); }
						  30% { transform: translate(0, 0); }
						  80% { transform: translate(0px, -20px); }
						  100% { transform: translate(0, -12px); }
						}
						@keyframes swordAnim2 {
						  0% { transform: translate(0, -6px); }
						  15% { transform: translate(0, 0); }
						  65% { transform: translate(0px, -20px); }
						  100% { transform: translate(0, -6px); }
						}
						@keyframes swordAnim3 {
						  0% { transform: translate(0, 0); }
						  50% { transform: translate(0px, -20px); }
						  100% { transform: translate(0, 0); }
						}
						.swJianYing img{
						position: absolute;
						width: 35px;
						height: 50px;
						pointer-events: none;
						z-index: 10;
						transform-origin: center center;
						}
						.swJianYing .shenquanjian{
						rotate: -45deg;
						animation: swordAnim1 4s infinite ease-in-out;
						}
						.swJianYing .renquanjian{
						rotate: 0deg;
						left: 30px;
						animation: swordAnim2 4s infinite ease-in-out;
						}
						.swJianYing .yiquanjian{
						rotate: 45deg;
						left: 60px;
						animation: swordAnim3 4s infinite ease-in-out;
						}
						`
					document.head.appendChild(style)
				}
				let div;
				if(!player?.node?.swJian) {
					div = ui.create.div('.swJianYing', player, {
						width: "80px",
						//height: "80px",
						left: "12px",
						transform: "translateY(10px)",
						pointerEvents: "none",
						overflow: "visible",
						display: "flex",
						alignItems: "center",
						zIndex: "201",
						position: "relative",
					});
					div.num = 0;
					player.node.swJian = div;
				}
				else {
					div = player.node.swJian;
				}
				if(!div.num) div.startTime = performance.now();
				const img = document.createElement('img');
				img.src = `${lib.assetURL}extension/${swTool.extensionName}/assets/image/${name}.png`;
				img.classList.add(name);
				const elapsed = (performance.now() - div.startTime) % 4000;
				img.style.animationDelay = `-${elapsed}ms`;
				div.num = (div.num || 0) + 1;
				div.appendChild(img);
				game.broadcast((player, name) => {
					lib.skill.swe_fengdu.createSword(player, name);
				}, player, name)
			},
			removeSword(player, name) {
				if(!player?.node?.swJian) return;
				const div = player.node.swJian;
				const target = div.querySelector(`.${name}`);
				if(target) {
					target.remove();
					div.num = Math.max((div.num || 0) - 1, 0);
				}
				game.broadcast((player, name) => {
					lib.skill.swe_fengdu.removeSword(player, name);
				}, player, name)
			},
			subSkill: {
				damage: {
					audio: ["swe_fengdu", 2],
					forced: true,
					firstDo: true,
					trigger: {
						source: "damageSource",
						player: "damageEnd",
					},
					filter(event, player) {
						return !player.hasSkill("swe_fengdu_yiquanjian") && event?.num > 1;
					},
					async content(event, trigger, player) {
						await player.addSkill("swe_fengdu_yiquanjian");
						await player.popup("异权剑");
						await game.delayx();
					},
				},
				renquanjian: {
					temp: true,
					init2(player) {
						lib.skill.swe_fengdu.createSword(player, "renquanjian");
						game.log(player, "获得了", "#g【人权剑】")
					},
					onremove(player) {
						lib.skill.swe_fengdu.removeSword(player, "renquanjian");
					},
				},
				shenquanjian: {
					temp: true,
					init2(player) {
						lib.skill.swe_fengdu.createSword(player, "shenquanjian");
						game.log(player, "获得了", "#g【神权剑】")
					},
					onremove(player) {
						lib.skill.swe_fengdu.removeSword(player, "shenquanjian");
					},
				},
				yiquanjian: {
					temp: true,
					init2(player) {
						lib.skill.swe_fengdu.createSword(player, "yiquanjian");
						game.log(player, "获得了", "#g【异权剑】")
					},
					onremove(player) {
						lib.skill.swe_fengdu.removeSword(player, "yiquanjian");
					},
				},
			},
			ai: {
				order: 4,
				threaten: function (player, target) {
					if(player.hasHistory("useSkill", evt => {
						return evt.skill == "swe_fengdu";
					})) return 1;
					return 0.7;
				},
				result: {
					player: 1,
				},
				effect: {
					target(card, player, target) {
						if(!player.hasHistory("useSkill", evt => {
							return evt.skill == "swe_fengdu";
						}) &&
							["basic", "trick"].includes(get.info(card).type)
						) return [1, 1];
						return;
					},
					player(card, player, target, result) {
						if(!player.hasHistory("useSkill", evt => {
								return evt.skill == "swe_fengdu";
							}) &&
							["basic", "trick"].includes(get.info(card).type)
						) return [1, 1];
						return;
					},
				},
			},
		},
		swe_yijian: {
			audio: `${ea}katixiya:2`,
			enable: "phaseUse",
			usable: 1,
			filterTarget(card, player, target) {
				return true;
			},
			ai2(target) {
				const player = get.player();
				return lib.suit.filter(s => !target.getCards('h').map(card => get.suit(card)).includes(s)).length * get.attitude(player, target) * ((player.countCards("h") > 10 && player === target) ? 0 : 1);
			},
			async content(event, trigger, player) {
				const target = event.target;
				const cards = [];
				const suit = lib.suit.filter(s => !target.getCards('h').map(card => get.suit(card)).includes(s));
				for(const s of suit) {
					const card = get.cardPile2(function (card) {
						return get.suit(card) == s;
					});
					if (card) cards.push(card);
				}
				if (cards.length) {
					await target.gain(cards, "gain2");
					if(cards.length >= 2) {
						await player.addSkill("swe_fengdu_renquanjian");
						await player.popup("人权剑");
					}
				}
				await game.delayx();
			},
			ai: {
				order() {
					var player = _status.event.player;
					return (lib.suit.filter(s => !player.getCards('h').map(card => get.suit(card)).includes(s)).length + 0.01) * 2;
				},
				result: {
					player(player) {
						return lib.suit.filter(s => !player.getCards('h').map(card => get.suit(card)).includes(s)).length
					},
				},
			},
		},
		swe_qiyuan: {
			limited: true,
			skillAnimation: false,
			enable: "phaseUse",
			audio: `${ea}katixiya:2`,
			selectCard: [-1, -2],
			filterTarget(card, player, target) {
				if(ui.selected.targets.length) return true;
				if(player === target) {
					player.classList.add("selected");
					ui.selected.targets.add(player);
					game.check();
					return true;
				}
				return false;
			},
			selectTarget: 1,
			filterCard: () => false,
			filter(event, player) {
				return !player.hasHistory("useSkill", evt => {
						return evt.skill == "swe_qiyuan";
					}) &&
					(
						player.getHistory('useCard').map(evt => get.suit(evt.card)).unique().filter(i => lib.suit.includes(i)).length >= 4 ||
						(player.hasSkill("swe_fengdu_shenquanjian") && player.hasSkill("swe_fengdu_yiquanjian") && player.hasSkill("swe_fengdu_renquanjian"))
					)
			},
			async contentBefore(event, trigger, player) {
				if(typeof game.playSkillVideo === "function") {
					game.broadcastAll(function () {
						game.playSkillVideo("kati1", 3700);
					})
					await game.delay(0, 3700);
				}
			},
			async content(event, trigger, player) {
				await player.awakenSkill(event.name);
				if(player.getHp(true) > Math.floor((player.maxHp + 1) / 2)) {
					const delt = player.getHp(true) - Math.floor((player.maxHp + 1) / 2);
					if (delt != 0) {
						const next = player.changeHp(-delt);
						next._triggered = null;
						await next;
					}
				}
				await player.changeCharacter(["swe_fuludelisi"]);
				await player.restoreSkill("swe_chaonu", true);
			},
			ai: {
				order() {
					const player = get.player();
					if(player.hasSkill("swe_fengdu_shenquanjian") && player.hasSkill("swe_fengdu_yiquanjian") && player.hasSkill("swe_fengdu_renquanjian")) return 114514;
					return 0;
				},
				result: {
					player(player) {
						return (player.hasSkill("swe_fengdu_shenquanjian") + player.hasSkill("swe_fengdu_yiquanjian") + player.hasSkill("swe_fengdu_renquanjian") * 2)
					},
				},
			}
		},
		// 芙露德莉斯
		swe_jueyi: {
			audio: `${ea}katixiya:4`,
			persevereSkill: true,
			trigger: {
				player: ["swe_jueyi_beginAfter", "swe_jueyi_addAfter"],
			},
			filter(event, player) {
				let skills = [];
				if (player?.additionalSkills?.swe_jueyi) skills.addArray(player.additionalSkills.swe_jueyi);
				return player.countMark("swe_jueyi") >= 120 * skills.length;
			},
			direct: true,
			beginMarkCount: 0,
			maxMarkCount: 120,
			derivation: ["swe_chaonu"],
			onremove: true,
			addMark(player, num) {
				num = Math.min(num, lib.skill.swe_jueyi.maxMarkCount - player.countMark("swe_jueyi"));
				if(num > 0) player.addMark("swe_jueyi", num);
			},
			async content(event, trigger, player) {
				const derivation = lib.skill.swe_jueyi.derivation,
					skills = player.countMark("swe_jueyi") == lib.skill.swe_jueyi.maxMarkCount ? derivation : derivation.slice(0, Math.floor(player.countMark("swe_jueyi") / 120));
				player.addAdditionalSkill("swe_jueyi", skills);
			},
			marktext: "决",
			intro: {
				name: "决意",
				content: "当前决意点数为#",
			},
			group: ["swe_jueyi_begin", "swe_jueyi_add", "swe_jueyi_clear"],
			subSkill: {
				begin: {
					persevereSkill: true,
					trigger: { player: "changeCharacterAfter" },
					forced: true,
					async content(event, trigger, player) {
						if(player.hasSkill("swe_fengdu_shenquanjian")) {
							await player.removeSkill("swe_fengdu_shenquanjian")
							lib.skill.swe_jueyi.addMark(player, 20);
							await player.addSkill("swe_jueyi_immunity");
						}
						if(player.hasSkill("swe_fengdu_yiquanjian")) {
							await player.removeSkill("swe_fengdu_yiquanjian")
							lib.skill.swe_jueyi.addMark(player, 20);
							await player.addSkill("swe_jueyi_damage");
						}
						if(player.hasSkill("swe_fengdu_renquanjian")) {
							await player.removeSkill("swe_fengdu_renquanjian")
							lib.skill.swe_jueyi.addMark(player, 20);
							await player.addSkill("swe_jueyi_jump");
						}
					},
				},
				add: {
					audio: ["swe_jueyi", 4],
					persevereSkill: true,
					trigger: {
						player: ["turnOverEnd", "linkEnd", "loseEnd"],
						source: "damageSource",
					},
					filter(event, player) {
						if (player.countMark("swe_jueyi") >= lib.skill.swe_jueyi.maxMarkCount) return false;
						if (event.name === "damage") return event.num > 1;
						else if(event.name === "lose") {
							for (var i = 0; i < event.cards.length; i++) {
								if (event.cards[i].original == "h" && player.countCards('h', card => get.suit(event.cards[i]) === get.suit(card)) <= 0) return true;
							}
							return false;
						}
						return true;
					},
					forced: true,
					async content(event, trigger, player) {
						let toAdd = (event.triggername === "damageSource") * 20 + (event.triggername !== "loseEnd" && event.triggername !== "damageSource") * 40;
						if(event.triggername === "loseEnd") {
							const evt = event.getTrigger();
							const list = [];
							for (var i = 0; i < evt.cards.length; i++) {
								if (evt.cards[i].original == "h" &&
									player.countCards('h', card => get.suit(evt.cards[i]) === get.suit(card)) <= 0 &&
									!list.includes(get.suit(evt.cards[i]))
								) {
									toAdd += 10;
									list.push(get.suit(evt.cards[i]))
								}
							}
						}
						lib.skill.swe_jueyi.addMark(player, toAdd);
					},
				},
				clear: {
					charlotte: true,
					trigger: { global: "roundStart" },
					direct: true,
					async content(event, trigger, player) {
						const list = ["jump", "damage", "immunity"];
						for(const i of list) {
							const name = `swe_jueyi_${i}`;
							if(player.hasSkill(name)) {
								player.setStorage(name, player.getStorage(name, 0) - 1);
								if(player.getStorage(name, 0) <= 0) player.removeSkill(name);
							}
						}
					},
				},
				jump: {
					charlotte: true,
					temp: true,
					init2(player) {
						player.setStorage("swe_jueyi_jump", 2);
					},
					trigger: {
						player: ["phaseDiscardBefore", "phaseJudgeBefore"],
					},
					onremove: true,
					mark: true,
					marktext: "人",
					intro: {
						name: "人权之心",
						content: function (storage, player, skill) {
							return `始终跳过判定和弃牌阶段<br>剩余持续轮次：${player.getStorage("swe_jueyi_jump", 0)}`;
						},
					},
					forced: true,
					async content(event, trigger, player) {
						trigger.cancel();
						//player.logSkill(event.name);
						game.log(player, "跳过了", "#y" + event.triggername == "phaseDiscardBefore" ? "弃牌阶段" : "判定阶段");
					},
				},
				damage: {
					charlotte: true,
					temp: true,
					trigger: { source: "damageBegin1" },
					init2(player) {
						player.setStorage("swe_jueyi_damage", 2);
					},
					onremove: true,
					mark: true,
					marktext: "异",
					intro: {
						name: "异权之力",
						content: function (storage, player, skill) {
							return `每回合首次造成的伤害+1<br>剩余持续轮次：${player.getStorage("swe_jueyi_damage", 0)}`;
						},
					},
					filter(event, player) {
						return (
							game
								.getGlobalHistory(
									"everything",
									evt => {
										return evt.name == "damage" && evt.source == player;
									},
									event
								)
								.indexOf(event) == 0 &&
							event.player.isIn()
						);
					},
					logTarget: "player",
					forced: true,
					async content(event, trigger, player) {
						trigger.num += 1;
						//player.logSkill(event.name);
					},
				},
				immunity: {
					charlotte: true,
					temp: true,
					trigger: { player: "damageBegin4" },
					init2(player) {
						player.setStorage("swe_jueyi_immunity", 2);
					},
					onremove: true,
					mark: true,
					marktext: "神",
					intro: {
						name: "神权之意",
						content: function (storage, player, skill) {
							return `当你受到伤害时，你可以弃置一张装备牌防止之<br>剩余持续轮次：${player.getStorage("swe_jueyi_immunity", 0)}`;
						},
					},
					async cost(event, trigger, player) {
						event.result = await player
							.chooseToDiscard("he", { type: "equip" }, false)
							.set(
								"prompt",
								'###神权之意###<div class="text center">你可以弃置一张装备牌并防止此伤害</div>'
							)
							.set("ai", function (card) {
								var player = _status.event.player;
								if (player.hp == 1 || _status.event.getTrigger().num > 1) {
									return 10 - get.value(card);
								}
								if (player.hp == 2) {
									return 8 - get.value(card);
								}
								return 7 - get.value(card);
							})
							.forResult();
					},
					async content(event, trigger, player) {
						trigger.cancel();
						//player.logSkill(event.name);
					},
					ai: {
						threaten: function (player, target) {
							if(player.countCards("he", { type: "equip" })) return 0.6;
							return 1;
						},
					},
				},
			},
			ai: {
				effect: {
					target(card, player, target) {
						if(get.name(card) == "tiesuo") return [1, 2];
					},
					player(card, player, target) {
						if(!player.hasCard(cd => get.suit(cd) == get.suit(card),'h')) return [1, 1];
					},
				},
			}
		},
		swe_chaonu: {
			audio: `${ea}katixiya:2`,
			limited: true,
			skillAnimation: false,
			enable: "phaseUse",
			filterTarget: lib.filter.notMe,
			position: "he",
			filterCard: true,
			selectCard: [0, Infinity],
			filter(event, player) {
				return player.countMark("swe_jueyi") >= 120;
			},
			complexSelect: true,
			ai1(card) {
				if(!ui?.selected?.targets?.length) return 0;
				const target = ui?.selected?.targets[0];
				const player = get.player();
				if(ui.selected.cards?.length >= Math.min(target.countCards('h'), 4)) return -114514;
				return 8 - get.value(card);
			},
			ai2(target) {
				const player = get.player();
				return get.damageEffect(target, player, player) * target.countCards('h') ;
			},
			async contentBefore(event, trigger, player) {
				if(typeof game.playSkillVideo === "function") {
					game.broadcastAll(function () {
						game.playSkillVideo("kati2", 5300);
					})
					await game.delay(0, 5300);
				}
			},
			async content(event, trigger, player) {
				await player.awakenSkill(event.name);
				// 下雨特效
				game.broadcastAll(() => {
					const raindropCount = 200;
					if(!_status.swYuCSS) {
						_status.swYuCSS = true
						const style = document.createElement('style')
						style.innerHTML = `
						.raindrop {
						  position: absolute;
						  width: 2px;
						  background: #aaa;
						  opacity: 0.6;
						  animation: fall 1s linear forwards;
						}
					
						@keyframes fall {
						  from {
							transform: translateY(0);
						  }
						  to {
							transform: translateY(100vh);
						  }
						}
						`
						document.head.appendChild(style)
					}
					for (let i = 0; i < raindropCount; i++) {
						const delay = Math.random() * 6000;
						setTimeout(() => {
							const drop = document.createElement('div');
							drop.className = 'raindrop';
							drop.style.left = Math.random() * window.innerWidth + 'px';
							drop.style.top = '0px';
							drop.style.pointerEvents = 'none';
							drop.style.height = 30 + Math.random() * 20 + 'px';
							drop.addEventListener('animationend', () => {
								drop.remove();
							});
							document.body.appendChild(drop);
						}, delay);
					}
				})
				// 剑痕特效
				game.broadcastAll(() => {
					_status.oldLineXY = game.linexy;
					game.linexy = function (...args) {
						try {
							return _status.oldLineXY.apply(this, args);
						} finally {
							game.linexy = _status.oldLineXY;
							delete _status.oldLineXY;
							const path = args[0];
							const from = [path[0], path[1]],
								to = [path[2], path[3]];
							const line = document.createElement('line');
							const dx = to[0] - from[0];
							const dy = to[1] - from[1];
							const angle = Math.atan2(dy, dx) * 180 / Math.PI;
							const screenHypot = Math.hypot(window.innerWidth, window.innerHeight);
							const length = Math.sqrt(dx*dx + dy*dy) + screenHypot;
							line.style.left = from[0] + 'px';
							line.style.top = from[1] + 'px';
							line.style.transform = `rotate(${angle}deg)`;
							line.style.width = length + 'px';
							line.style.position = 'absolute';
							line.style.height = '2px';
							line.style.background = '#7FDBFF';
							line.style.boxShadow = '0 0 8px #7FDBFF, 0 0 16px #7FDBFF';
							line.style.transformOrigin = 'left center';
							line.style.zIndex = '10';
							line.style.pointerEvents = 'none';
							line.style.opacity = '0';
							line.style.transitionDuration = '4s';
							requestAnimationFrame(() => {
								line.style.opacity = '1';
							});
							setTimeout(() => {
								line.style.opacity = '0';
								line.addEventListener('transitionend', () =>
									line.remove()
								);
							}, 60000);
							if (game.chess) ui.chess.appendChild(line);
							else ui.arena.appendChild(line);
						}
					};
				})
				player.line(event.target);
				await event.target.damage(Math.min(lib.suit.map(suit => event.target.getCards('h').map(card => get.suit(card)).includes(suit) ? [suit] : []).flat().length, event?.cards?.length || 0) || 1, player);
				await game.delayx();
				const list = ["jump", "damage", "immunity"];
				for await (const i of list) {
					const name = `swe_jueyi_${i}`;
					if(player.hasSkill(name)) {
						await player.removeSkill(name);
					}
				}
				//await player.recover(Math.floor(player.maxHp / 2));
				await player.removeMark("swe_jueyi", 120, false);
				await player.changeCharacter(["swe_katixiya"]);
				await player.restoreSkill("swe_qiyuan");
			},
			ai: {
				threaten: 1.2,
				expose: 0.8,
				order: 114514,
				result: {
					player: 1,
				},
			},
		},




		sw_shangzhuo: {
			audio: ["dcjinjin"],
			trigger: { player: "damageEnd" },
			unique: true,
			forced: true,
			juexingji: true,
			skillAnimation: true,
			animationColor: "water",
			content: function () {
				"step 0";
				var list;
				if (_status.characterlist) {
					list = [];
					for (var i = 0; i < _status.characterlist.length; i++) {
						var name = _status.characterlist[i];
						list.push(name);
					}
				} else if (_status.connectMode) {
					list = get.charactersOL(function (i) {
						return false;
					});
				} else {
					list = get.gainableCharacters(function (info) {
						return true;
					});
				}
				var players = game.players.concat(game.dead);
				for (var i = 0; i < players.length; i++) {
					list.remove(players[i].name);
					list.remove(players[i].name1);
					list.remove(players[i].name2);
				}
				// var dialog=ui.create.dialog();
				// dialog.add([list.randomGets(5),'character']);
				player
					.chooseButton(true)
					.set("ai", function (button) {
						return get.rank(button.link, true) - lib.character[button.link][2];
					})
					.set("createDialog", ["将武将牌替换为一名角色", [list.randomGets(player.countCards("h") + 1), "character"]]);//改为X张
				player.awakenSkill("sw_shangzhuo");
				"step 1";
				player.disableJudge();
				player.reinitCharacter(get.character(player.name2, 3).includes("sw_shangzhuo") ? player.name2 : player.name1, result.links[0]);
				if (3 - player.maxHp > 0) player.gainMaxHp(3 - player.maxHp);
				else if (player.maxHp - 3 > 0) player.loseMaxHP(player.maxHp - 3);
				player.recover();
			},
		},
		sw_heping: {
			audio: ["dcjinjin"],
			trigger: {
				global: "phaseBefore",
				player: "enterGame",
			},
			forced: true,
			filter(event, player) {
				return event.name != "phase" || game.phaseNumber == 0;
			},
			logTarget: function () {
				return game.filterPlayer(function (current) {
					return !current.hasSkill("sw_heping_1");
				});
			},
			onremove: true,
			content: function () {
				var targets = lib.skill.sw_heping.logTarget().sortBySeat();
				for (var target of targets) {
					player.line(target);
					target.addSkill("sw_heping_1");
				}
				game.delayx();
			},
			mod: {
				ignoredHandcard: function (card, player) {
					if (get.suit(card, player) == "diamond") return true;
				},
			},
			subSkill: {
				1: {
					charlotte: true,
					mark: true,
					marktext: "和",
					intro: {
						name: "和平",
						content: "你的♠牌和♠判定牌的花色视为♥，♣牌和♣判定牌的花色视为♦",
					},
					mod: {
						suit(card, suit) {
							if (suit == "spade") return "heart";
							if (suit == "club") return "diamond";
						},
					},
				},
			},
		},
		sw_gugu: {
			audio: ["dchaochong", 2],
			trigger: {
				global: "phaseBefore",
				player: ["phaseJieshuBegin", "enterGame"],
			},
			filter: function (event, player, name) {
				if (player.hasJudge("lebu")) return false;
				return (event.name != "phase" || game.phaseNumber == 0 || name == "phaseJieshuBegin") && player.countCards("hes", { suit: "diamond" }) > 0;
			},
			locked: false,
			discard: false,
			delay: false,
			prepare: "throw",
			position: "he",
			//filterCard: function (card, player, event) {
			//	return get.suit(card) == "diamond" && player.canAddJudge({ name: "lebu", cards: [card] });
			//},
			content() {
				"step 0";
				player.chooseCard("hes", "【咕咕】：选择一张♦牌当做【乐不思蜀】置入你的判定区",  (card, player) => {
					return get.suit(card) == "diamond" && player.canAddJudge({ name: "lebu", cards: [card] });
				});
				"step 1";
				if (result.bool) {
					player.$throw(result.cards[0]);
					player.addJudge({ name: "lebu" }, result.cards[0]);
				}
				else event.finish();
				"step 1";
				player.draw(1);
			},
			group: ["sw_gugu_1"],
			subSkill: {
				1: {
					audio: ["dchaochong", 2],
					trigger: { target: "useCardToTargeted" },
					forced: true,
					filter(event, player) {
						return player.countCards("j") && event.targets.length == 1;
					},
					content: function () {
						trigger.getParent().excluded.add(player);
					},
				},
			},
		},

		sw_tonghun: {
			trigger: {
				global: "phaseBefore",
				player: "enterGame",
			},
			filter(event) {
				return event.name != "phase" || game.phaseNumber == 0;
			},
			async cost(event, trigger, player) {
				event.result = await player.chooseTarget('选择一名角色与其获得“同婚”标记<br>且其回复体力后你回复等量体力，其摸牌后你摸等量牌', lib.filter.notMe).set('ai', target => {
					return get.attitude(_status.event.player, target)
				}).forResult()
			},
			init(player) {
				player.storage.sw_tonghunTargets = []
				//game.addGlobalSkill('sw_caibu')
			},
			async content(event, trigger, player) {
				for (const target of event.targets) {
					target.addMark('sw_tonghun', 1)
					player.markCharacter(target.name)
					player.storage.sw_tonghunTargets.push(target)
				}
				player.addMark('sw_tonghun', 1)
				player.addSkill('sw_tonghun_xianfu')
			},
			onreset(player) {
				game.players.forEach(current => {
					current.clearMark('sw_tonghun')
					current.unmarkSkill('sw_tonghun')
				})
				player.remove('sw_tonghun_xianfu')
			},
			onremove(player) {
				game.removeGlobalSkill('sw_caibu')
				game.players.forEach(current => {
					current.clearMark('sw_tonghun')
					current.unmarkSkill('sw_tonghun')
				})
				player.remove('sw_tonghun_xianfu')
			},
			mark: true,
			marktext: "嫁",
			intro: {
				name: "同婚",
				content(err, player) {
					return `同婚标记个数为${player.countMark('sw_tonghun')}`
				},
				markcount(err, player) {
					return `${player.countMark('sw_tonghun')}`
				}
			},
		},
		sw_renjie_mark: {
			//mark: true,
			direct: true,
			marktext: "精",
			intro: {
				name: "精气",
				content: function (storage, player) {
					return get.translation(player.name) + "通过戒鹿获得的精气，手牌上限+" + player.countMark("sw_renjie_mark");
				},
			},
			onremove: true,
			mod: {
				maxHandcard(player, num) {
					return num + player.countMark("sw_renjie_mark");
				},
			},
		},
		sw_renjie: {
			audio: ["dchaochong", 2],
			init: player => {
				player.addSkill("sw_renjie_mark");
			},
			trigger: { source: "damageBegin4" },
			forced: true,
			content() {
				player.addMark("sw_renjie_mark", Math.min((5 - player.countMark("sw_renjie_mark")), trigger.num * 2));
				trigger.cancel();
			},
			group: ["sw_renjie_1"],
			subSkill: {
				1: {
					audio: ["dchaochong", 2],
					trigger: { player: "damageBegin3" },
					forced: true,
					content() {
						if (trigger.num > 2) trigger.num = 2;
						player.addMark("sw_renjie_mark", Math.min((5 - player.countMark("sw_renjie_mark")), 1));
						player.logSkill("sw_renjie");
					},
				},
			}
		},
		sw_sanyang: {
			audio: ["dchaochong", 2],
			trigger: { target: "useCardToTargeted" },
			filter(event, player) {
				return player.hasMark("sw_renjie_mark") && player.countMark("sw_renjie_mark") >= 1;
			},
			content: function () {
				player.removeMark("sw_renjie_mark", 1);
				trigger.targets.length = 0;
				trigger.getParent().triggeredTargets1.length = 0;
			},
		},
		sw_luguan: {
			audio: ["dcjinjin", 2],
			enable: "phaseUse",
			usable: 1,
			filter(event, player) {
				return player.hasMark("sw_renjie_mark") && player.countMark("sw_renjie_mark") >= 1;
			},
			skillAnimation: true,
			animationColor: "ice",
			filterTarget: function (card, player, target) {
				return target != player;
			},
			content() {
				"step 0";
				event.num3 = player.countMark("sw_renjie_mark");
				event.num = player.countMark("sw_renjie_mark");
				player.removeMark("sw_renjie_mark", event.num);
				event.num2 = event.num * 2 + Math.floor(Math.random() * (15 - 4 + 1)) + 4;
				event.time = get.utc();
				event.num = 0;
				"step 1";
				player.chooseBool("是否继续鹿关？").ai = function () {
					return true;
				};
				event.num++;
				"step 2";
				if (result.bool && event.num < event.num2) event.goto(1);
				else if (result.bool && event.num >= event.num2) event.goto(3);
				else {
					game.log(player, "鹿关总次数：" + event.num);
					game.log(player, "鹿关失败...阳气散尽...");
					event.finish();
				}
				"step 3";
				game.log(player, "鹿关总次数：" + event.num);
				game.log(player, "鹿关成功！");
				game.log(player, "鹿关总时长：" + Math.round((get.utc() - event.time) / 100) / 10 + "s");
				player.line(target);
				player.logSkill("对着TA鹿关了！", target);
				target.damage("fire", Math.max(0, Math.min(Math.round(event.num3 * (event.num2 / 8) / (Math.round((get.utc() - event.time) / 100) / 10)), 2)), "nocard");
				player.addMark("sw_luguan_mark", 1);
				//获得技能
				if (target.hasSex("female")) {
					if (!target.hasSkill("sw_haixiu")) target.addSkill("sw_haixiu");
				}
				else {
					if (!target.hasSkill("sw_fenmen")) target.addSkill("sw_fenmen");
				}
				"step 4";
				if (player.countMark("sw_luguan_mark") >= 3) {
					player.die();
				}
			},
			subSkill: {
				mark: {
					direct: true,
					marktext: "鹿",
					intro: {
						name: "鹿关",
						content: "当前鹿关次数#",
					},
				},
			},
		},
		sw_haixiu: {
			forced: true,
			trigger: { player: "gainAfter" },
			logTarget: "player",
			content() {
				player.addMark("sw_haixiu_mark", trigger.cards.length);
				if (player.countMark("sw_haixiu_mark") >= 8) {
					var num = Math.floor(player.countMark("sw_haixiu_mark") / 8);
					player.loseHp(num);
					player.removeMark("sw_haixiu_mark", num * 8);
				}
			},
			group: ["sw_haixiu_mark"],
			subSkill: {
				mark: {
					mark: true,
					direct: true,
					marktext: "羞",
					intro: {
						name: "害羞",
						content: "mark",
					},
				},
			},
		},
		sw_fenmen: {
			forced: true,
			trigger: { source: "damageEnd" },
			logTarget: "player",
			content() {
				player.addMark("sw_fenmen_mark", trigger.num);
				if (player.countMark("sw_fenmen_mark") >= 3) {
					var num = Math.floor(player.countMark("sw_fenmen_mark") / 3);
					player.loseHp(num);
					player.removeMark("sw_fenmen_mark", num * 3);
				}
			},
			group: ["sw_fenmen_mark"],
			subSkill: {
				mark: {
					mark: true,
					direct: true,
					marktext: "愤",
					intro: {
						name: "愤懑",
						content: "mark",
					},
				},
			},
		},
		sw_xinhuo: {
			init: function (player) {
				player.storage.cnt = 0;
				//player.syncStorage("cnt");
			},
			audio: ["dcjinjin", 2],
			trigger: {
				player: "useCardEnd",
			},
			forced: true,
			content: function () {
				player.addMark("sw_xinhuo_mark", 1);
				if (!(player.countMark("sw_xinhuo_mark") % 2)) {
					var skills = game.filterSkills(
						player.getStockSkills(true, true).filter(skill => {
							const info = get.info(skill);
							return !info.persevereSkill || !info.charlotte;
						}),
						player
					);
					var num = 1;
					skills = skills.slice(0, num);
					if (skills[0] == "sw_xinhuo") player.loseMaxHp();
					player.disableSkill("sw_xinhuo", skills);
					player.addTempSkill("sw_xinhuo_restore");
					player.storage.cnt += 1;
					//player.syncStorage("cnt");
					var str = "";
					for (var i of skills) {
						str += "【" + get.translation(i) + "】、";
						player.popup(i);
					}
					str = str.slice(0, -1);
					game.log(player, "的技能", "#g" + str, "失效了");
					player.draw(player.storage.cnt);
				}
			},
			subSkill: {
				restore: {
					charlotte: true,
					forced: true,
					popup: false,
					onremove: function (player) {
						player.enableSkill("sw_xinhuo");
						player.storage.cnt = 0;
						game.log(player, "恢复了技能");
						player.removeMark("sw_xinhuo_mark", player.countMark("sw_xinhuo_mark"));
					},
				},
				mark: {
					direct: true,
					marktext: "火",
					intro: {
						name: "心火",
						content: "本回合使用牌数#",
					},
				},
			},
		},
		sw_shangshi: {
			audio: ["dchaochong", 2],
			trigger: { player: "phaseJieshuBegin" },
			init: function (player) {
				if (!player.storage.sw_shangshi) player.storage.sw_shangshi = [3, 3];
			},
			getInfo: function (player) {
				if (!player.storage.sw_shangshi) player.storage.sw_shangshi = [3, 3];
				return player.storage.sw_shangshi;
			},
			broadcast(card) {
				game.broadcast(
					(card, storage) => {
						card.storage = storage;
					},
					card,
					card.storage
				);
			},
			//recordGuPiao: function (player, target, color, num) {
			//	if (!player.storage.sw_shangshi_record) player.storage.sw_shangshi_record = {};
			//	if (!player.storage.sw_shangshi_record.target) player.storage.sw_shangshi_record.target = {red: 0,black: 0};

			//	if (color == "red") player.storage.sw_shangshi_record.target.red += num;
			//	else player.storage.sw_shangshi_record.target.black += num;
			//	//alert(player.storage.sw_shangshi_record.target.red);
			//},
			filter: function (event, player) {
				return player.countCards("he") && player.maxHp > 0;
			},
			content: function* (event, map) {
				"step 0";
				var player = map.player;
				var list = lib.skill.sw_shangshi.getInfo(player);
				var num = list[0];
				var result = yield player
					.chooseCard(get.prompt("sw_shangshi"), "将至多" + get.cnNumber(num) + "张牌称为“股”置于武将牌上并摸等量的牌或取消可以选择进行判定", "he", [1, num])
					.set("complexCard", true)
					.set("triggerName", event.triggername);
				if (result.bool) {
					player.logSkill("sw_shangshi");
					for (var k of result.cards) {
						//k.storage.sw_shangshi_hidden = true;
						//投股记录
						//lib.skill.sw_shangshi.recordGuPiao(player, player, get.color(k), 1);

						var color = get.color(k);
						//if (!player.storage.sw_shangshi_record) player.storage.sw_shangshi_record = {};
						//if (!player.storage.sw_shangshi_record.player) player.storage.sw_shangshi_record.player = { red: 0, black: 0 };
						//if (color == "red") player.storage.sw_shangshi_record.player.red += 1;
						//else player.storage.sw_shangshi_record.player.black += 1;
						if (!player.storage.sw_shangshi_record) player.storage.sw_shangshi_record = 0;
						if (color == "red") player.storage.sw_shangshi_record += 1;
					}
					//alert(player.storage.sw_shangshi_record.player.red);

					//player.$throw(result.cards, 1000);
					player.lose(result.cards, ui.cardPile, "insert");
					game.log(player, "将" + get.cnNumber(result.cards.length) + "张牌置于了牌堆顶");
					player.addToExpansion(result.cards, player, "draw").gaintag.add("sw_shangshi");

					player.draw(result.cards.length);
					if (player.hujia == 0) player.changeHujia();

					event.finish();
				}
				else event.goto(1);
				"step 1";
				result.bool = player.chooseBool("是否进行一次判定并将判定牌称为“股”置于武将牌上");
				"step 2";
				if (result.bool) {
					player.logSkill("sw_shangshi");
					player.judge(card => 1).callback = lib.skill.sw_shangshi.callback;
				}
			},
			callback: function () {
				if (typeof card.number == "number") {

					if (!card.storage) card.storage = {};
					card.storage.sw_shangshi_hidden = true;
					lib.skill.sw_shangshi.broadcast(card);

					player.addToExpansion(card, "gain2").gaintag.add("sw_shangshi");
					player.popup("判定生效", "wood");
				}
			},
			marktext: "股",
			intro: {
				markcount: "expansion",
				mark(dialog, content, player) {
					const cards = player.getExpansions("sw_shangshi"),
						hidden = cards.filter(card => !card.storage.sw_shangshi_hidden),
						dis = cards.removeArray(hidden);
					dialog.addText("股票形势");
					if (dis.length) dialog.addSmall(dis);
					else dialog.addText("暂无明股");
					if (hidden.length) {
						return "此外，还有" + get.cnNumber(hidden.length) + "张暗“股”，在无形间改变股票形势";
					}
				},
				content(content, player) {
					const cards = player.getExpansions("sw_shangshi"),
						hidden = cards.filter(card => card.storage.sw_shangshi_hidden),
						dis = cards.removeArray(hidden);
					dialog.addText("股票形势");
					if (dis.length) dialog.addSmall(dis);
					else dialog.addText("暂无明股");
					if (hidden.length) {
						return "此外，还有" + get.cnNumber(hidden.length) + "张暗“股”，在无形间改变股票形势";
					}
				},
			},
			onremove: function (player, skill) {//失去技能时失去所有的股票牌
				var cards = player.getExpansions(skill);
				if (cards.length) player.loseToDiscardpile(cards);
				player.storage.sw_shangshi_record = {};
			},
			group: ["sw_shangshi_1", "sw_shangshi_2"],
			subSkill: {
				1: {
					forced: true,
					trigger: { global: "phaseZhunbeiBegin" },
					popup: false,
					filter(trigger, player) {
						return trigger.player !== player && player.getExpansions("sw_shangshi").length;
					},

					async content(event, trigger, player) {
						const target = trigger.player
						player.logSkill("sw_shangshi");
						player.line(trigger.player);
						var num = lib.skill.sw_shangshi.getInfo(player)[1];
						var list = [], choiceList = ["将一张牌称为“股”置于" + get.translation(player) + "的武将牌上", "失去" + num + "点体力"];
						if (game.hasPlayer(target => target.countCards("he"))) list.push("入“股”");
						else choiceList[0] = '<span style="opacity:0.5">' + choiceList[0] + "</span>";
						list.push("失去体力");
						var str = "";
						for (var i of list) {
							str += i;
							str += "、";
						}
						str = str.slice(0, -1);
						list = list.filter(control => {
							if (control == "失去体力") return true;
							return target.countDiscardableCards(target, "he");
						});


						const {
							result: { control },
						} = await target.chooseControl(list)
							.set("prompt", "【上市②】：请选择一项")
							.set(
								"choiceList",
								choiceList.map(str => str)
							)
							.set("target", target);
						switch (control) {
							case "入“股”":
								const {
									result: { bool, cards },
								} = await trigger.player.chooseCard("he", choiceList[0], true);
								if (bool) {
									//target.$throw(cards, 1000);
									target.lose(cards, ui.cardPile, "insert");
									game.log(target, "将" + get.cnNumber(cards.length) + "张牌置于了牌堆顶");
									player.addToExpansion(cards, target, "draw").gaintag.add("sw_shangshi");
									//投股记录
									for (var k of cards) {
										var color = get.color(k);
										if (!target.storage.sw_shangshi_record) target.storage.sw_shangshi_record = 0;
										if (color == "red") target.storage.sw_shangshi_record += 1;
									}
								}
								break;
							case "失去体力":
								target.loseHp(num);
								break;
						}
						player.judge(card => 1).callback = lib.skill.sw_shangshi.callback;
					},
				},
				2: {
					forced: true,
					mod: {
						maxHandcard: function (player, num) {
							return num + lib.skill.sw_shangshi.getInfo(player)[0];
						},
					},
				},
			},
		},
		sw_kaipan: {
			audio: ["dcjinjin", 2],
			trigger: { player: "phaseZhunbeiBegin" },
			forced: true,
			filter(trigger, player) {
				return player.getExpansions("sw_shangshi").length;
			},
			content: function () {
				"step 0";
				player
					.chooseControl("<span class=firetext>涨涨涨</span>", "<span class=greentext>跌跌跌</span>")
					.set("prompt", "请预测股票：")
					.set("ai", function () {
						return Math.Random();
					});
				"step 1";
				event.boolGuPiao = (result.control == "<span class=firetext>涨涨涨</span>");
				//alert(event.boolGuPiao);
				var cards = player.getExpansions("sw_shangshi");
				var zhang = 0, die = 0;
				for (var k of cards) {
					if (get.color(k) == "red") zhang += get.number(k);
					if (get.color(k) == "black") die += get.number(k);
				}
				var res = zhang > die;
				event.boolRes = res;
				var str = `${get.translation(player)}的股票开盘！！：<br>涨幅度：<span class=firetext>${zhang}</span>  跌幅度：<span class=greentext>${die}</span><br>预测结果：${res == event.boolGuPiao ? "<span class=greentext>正确！</span>" : "<span class=firetext>错误！</span>"}`;
				//var dialog = ui.create.dialog(str, cards, true);
				event.videoId = lib.status.videoId++;
				game.broadcastAll(
					function (ss, cards, id) {
						var dialog = ui.create.dialog(ss, cards, true);
						dialog.videoId = id;
					},
					str,
					cards,
					event.videoId
				);
				game.delay(7);
				"step 2";
				game.broadcastAll('closeDialog', event.videoId);
				var targets = game.filterPlayer().sortBySeat(player);
				for (var k of targets) {
					if (k.storage.sw_shangshi_record) {
						if (event.boolRes) k.draw(2 * k.storage.sw_shangshi_record);
						else k.loseHp(k.storage.sw_shangshi_record);
					}
					k.storage.sw_shangshi_record = 0;
				}
				if (event.boolGuPiao == event.boolRes) {
					if (event.boolRes) {
						player.addTempSkill("dcjinjing");
						player.addTempSkill("sw_ziben");
					}
					else {
						player.recover();
						player.addTempSkill("fankui", { player: "phaseZhunbeiBegin" });
					}
				}
				else {
					var list = lib.skill.sw_shangshi.getInfo(player);
					var index = 0;
					if (!event.boolRes) index = 1;
					list[index] = Math.max(0, list[index] - 1);
					game.log(player, "将【上市", index == 0 ? "①" : "②", "】数字改为", "#y" + list[index]);
					player.markSkill("sw_shangshi");
				}
				"step 3";
				var cards = player.getExpansions("sw_shangshi");
				if (cards.length) {
					player.loseToDiscardpile(cards);

					for (var card of cards) {
						if (card && card.storage) {
							card.storage.sw_shangshi_hidden = false;
							lib.skill.sw_shangshi.broadcast(card);
						}
					}

					//game.broadcastAll(function (c) {
					//	for(var k of c){
					//		c.storage.sw_shangshi_hidden = false;
					//	}
					//}, cards);
				}

			},
		},
		sw_ziben: {
			trigger: { source: "damageEnd" },
			logTarget: "player",
			frequent: true,
			forced: false,
			filter: function (event, player) {
				if (event._notrigger.includes(event.player)) return false;
				return event.player != player && event.player.isIn() && event.player.countGainableCards(player, "hej") > 0;
			},
			check: function () {
				return false;
			},
			content: function () {
				player.gainPlayerCard(trigger.player, "he", false);
				player.line(trigger.player, "green");
			},
		},
		sw_tongpin2: {
			//audio: 2,
			group: ["sw_tongpin2_0", "sw_tongpin2_1", "sw_tongpin2_2", "sw_tongpin2_3"],
			subSkill: {
				0: {
					trigger: { global: "damageBegin3" },
					filter(event, player) {
						if (player.hasSkill("sw_tongpin2_round")) return false;
						return event.player && event.player.isIn() && event.player.hasMark("sw_tongpin_mark") && player.countCards("he") >= event.num;
					},
					forced: true,
					async content(event, trigger, player) {
						//"step 0";
						const num = trigger.num;
						const {
							result: { bool },
						} = await player.chooseToDiscard("he", num, get.prompt("sw_tongpin2", trigger.target), "弃置" + num + "张牌，并转移" + num + "点伤害给自己");
						//"step 1";
						if (bool) {
							player.discard(event.cards);
							player.damage(trigger.source ? trigger.source : "nosource");
							player.line(trigger.player);
							player.addTempSkill("sw_tongpin2_round", "roundStart");
							trigger.cancel();
						}
					},
				},
				1: {
					trigger: { global: "damageEnd" },
					filter(event, player) {
						return event.player && event.player.isIn() && event.player.hasMark("sw_tongpin_mark");
					},
					forced: true,
					logTarget: "player",
					content() {
						//trigger.player.recover(trigger.player.countMark("sw_tongpin_mark"));
						if (!player.hasSkill("sw_tongpin2_round")) {
							player.recover(trigger.player.countMark("sw_tongpin_mark"));
							player.addTempSkill("sw_tongpin2_round", "roundStart");
						}
						trigger.player.removeMark("sw_tongpin_mark", trigger.player.countMark("sw_tongpin_mark"));
						trigger.player.removeSkill("sw_tongpin_mark");
						if (player.isTurnedOver()) player.turnOver(false);
						player.removeSkill("sw_tongpin2");
						player.line(trigger.player);
					},
				},
				2: {
					trigger: {
						player: "turnOverBefore",
					},
					forced: true,
					filter(event, player) {
						return game.hasPlayer(function (current) {
							return current.hasMark("sw_tongpin_mark");
						});
					},
					content() {
						//player.logSkill("sw_tongpin");
						trigger.cancel();
					},
				},
				3: {
					trigger: {
						player: "damageBegin4",
					},
					forced: true,
					filter(event, player) {
						return game.hasPlayer(function (current) {
							return current.hasMark("sw_tongpin_mark");
						});
					},
					content() {
						//player.logSkill("sw_tongpin");
						trigger.cancel();
					},
				},
				round: {
					mark: true,
					marktext: "守",
					intro: { name: "同嫁", content: "本轮的伤害转移已使用" },
				},
			},
		},
		sw_tongpin: {
			enable: "phaseUse",
			usable: 1,
			filterTarget: function (card, player, target) {
				return target != player;
			},
			content() {
				"step 0";
				player.line(target);
				if (!player.isTurnedOver()) player.turnOver(true);
				"step 1";
				target.addSkill("sw_tongpin_mark");
				target.addMark("sw_tongpin_mark", 1);
				player.addSkill("sw_tongpin2");
			},
			subSkill: {
				mark: {
					trigger: { source: "damageBegin1" },
					forced: true,
					charlotte: true,
					filter: function (event, player) {
						return event.card.name == "sha";
					},
					content() {
						trigger.num++;
						game.log(player, "造成了", "#y暴击伤害");
					},
					marktext: "嫁",
					intro: {
						name: "同嫁",
						content: function (storage, player) {
							return "有女同嫁给了你！";
						},
					},
					mod: {
						cardUsable(card, player, num) {
							if (player.hasMark("sw_tongpin_mark") && card.name == "sha")
								return (
									num +
									game.countPlayer(function (current) {
										return current.hasSkill("sw_tongpin");
									})
								);
						},
					},
				},
			},

		},
		sw_zhinang: {
			audio: 2,
			trigger: { player: "useCardEnd", },
			forced: true,
			filter(event, player) {
				return get.zhinangs().includes(event.card.name) && event.card.isCard && event.cards && event.cards.length == 1;
			},
			content() {
				"step 0";
				if (!_status.zhinang_list) {
					var list,
						skills = [];
					//var banned = ["xunyi", "mbyilie"];
					if (get.mode() == "guozhan") {
						list = [];
						for (var i in lib.characterPack.mode_guozhan) list.push(i);
					} else if (_status.connectMode) list = get.charactersOL();
					else {
						list = [];
						for (var i in lib.character) {
							if (lib.filter.characterDisabled2(i) || lib.filter.characterDisabled(i)) continue;
							list.push(i);
						}
					}
					for (var i of list) {
						if (i.indexOf("gz_jun") == 0) continue;
						for (var j of lib.character[i][3]) {
							var skill = lib.skill[j];
							if (!skill || skill.zhuSkill) continue;
							if (skill.ai && (skill.ai.combo || skill.ai.notemp || skill.ai.neg)) continue;
							var info = get.translation(j + "_info");
							for (var ix = 0; ix < info.length - 4; ix++) {
								// 匹配四字成语
								if (/无懈可击|过河拆桥|顺手牵羊|无中生有|乐不思蜀/.test(info.substring(ix, ix + 4))) {
									skills.add(j);
									break;
								}
							}
						}
					}
					_status.zhinang_list = skills;
				}
				var list = _status.zhinang_list
					.filter(function (i) {
						return !player.hasSkill(i, null, null, false);
					})
					.randomGets(3);
				if (list.length == 0) game.log(player, "没有技能可选");
				else {
					event.videoId = lib.status.videoId++;
					var func = function (skills, id, target) {
						var dialog = ui.create.dialog("forcebutton");
						dialog.videoId = id;
						dialog.add("选择一个技能获得");
						for (var i = 0; i < skills.length; i++) {
							dialog.add('<div class="popup pointerdiv" style="width:80%;display:inline-block"><div class="skill">【' + get.translation(skills[i]) + "】</div><div>" + lib.translate[skills[i] + "_info"] + "</div></div>");
						}
						dialog.addText(" <br> ");
					};
					func(list, event.videoId, player);
					player.chooseControl(list).set("ai", function () {
						var controls = _status.event.controls;
						if (controls.includes("cslilu")) return "cslilu";
						if (controls.includes("zhichi")) return "zhichi";
						return controls[0];
					});
				}
				"step 1";
				game.broadcastAll("closeDialog", event.videoId);
				player.addSkills(result.control);
			},
		},
		sw_shenjincui: {
			audio: ["dcjincui", 2],
			trigger: {
				player: "phaseZhunbeiBegin",
			},
			forced: true,
			charlotte: true,
			filter: function (event, player) {
				return true;
			},
			content: function () {
				var num = 0;
				for (var i = 0; i < ui.cardPile.childNodes.length; i++) {
					var card = ui.cardPile.childNodes[i];
					if (get.zhinangs().includes(card.name)) num++;
				}
				game.log(player, "牌堆中剩余智囊数：" + num.toString());
				if (num > 9) {
					player.draw();
					player.gainMaxHp();
				}
				if (num >= 7) {
					player.addTempSkill("ssw_shenjincui_buff", { player: "phaseAfter" });
					player.addMark("sw_shenjincui_buff", 1, false);
				}
				if (num < 7) {
					if (player.MaxHp > 3) player.loseMaxHp(1);
				}
			},
			subSkill: {
				buff: {
					onremove: true,
					charlotte: true,
					mod: {
						cardUsable(card, player, num) {
							if (card.name == "sha") return num + player.countMark("sw_shenjincui_buff");
						},
					},
					mark: true,
					intro: {
						content: "本阶段内使用【杀】的次数上限+#",
					},
				},
			},
		},
		sw_kanpo: {
			init: function (player) {
				if (!player.storage.sbkanpo) {
					player.storage.sbkanpo = [12, [], []];
					player.markSkill("sbkanpo");
				}
			},
			audio: ["sbkanpo", 2],
			trigger: { global: "roundStart" },
			filter: function (event, player) {
				var storage = player.storage.sbkanpo;
				return storage[0] || storage[1].length;
			},
			forced: true,
			locked: false,
			content: function* (event, map) {
				var player = map.player,
					storage = player.storage.sbkanpo;
				var sum = storage[0];
				storage[1] = [];
				player.markSkill("sbkanpo");
				if (!sum) {
					"step 0";
					if (player.hasSkill("sw_kanpo")) player.removeSkill("sw_kanpo");
					player.addSkill("swq_jincui");
					var cards = [];
					for (var i of get.zhinangs()) {
						var card = get.cardPile2(function (card) {
							return card.name == i;
						});
						if (card) cards.push(card);
					}
					if (cards.length) player.gain(cards, "gain2");
					return;
				}
				const list = get.inpileVCardList(info => {
					if (info[2] == "sha" && info[3]) return false;
					//return info[0] != "equip";
					return true;
				});
				const func = () => {
					const event = get.event();
					const controls = [
						link => {
							const evt = get.event();
							if (evt.dialog && evt.dialog.buttons) {
								for (let i = 0; i < evt.dialog.buttons.length; i++) {
									const button = evt.dialog.buttons[i];
									button.classList.remove("selectable");
									button.classList.remove("selected");
									const counterNode = button.querySelector(".caption");
									if (counterNode) {
										counterNode.childNodes[0].innerHTML = ``;
									}
								}
								ui.selected.buttons.length = 0;
								game.check();
							}
							return;
						},
					];
					event.controls = [ui.create.control(controls.concat(["清除选择", "stayleft"]))];
				};
				if (event.isMine()) func();
				else if (event.isOnline()) event.player.send(func);
				var result = yield player
					.chooseButton(["看破：是否记录至多" + get.cnNumber(sum) + "个牌名？", [list, "vcard"]], [1, sum], false)
					.set("ai", function (button) {
						//if (ui.selected.buttons.length >= Math.max(3, game.countPlayer() / 2)) return 0;
						switch (button.link[2]) {
							case "wuxie":
								return 5 + Math.random();
							case "sha":
								return 5 + Math.random();
							case "tao":
								return 4 + Math.random();
							case "jiu":
								return 3 + Math.random();
							case "lebu":
								return 3 + Math.random();
							case "shan":
								return 4.5 + Math.random();
							case "wuzhong":
								return 4 + Math.random();
							case "shunshou":
								return 2.7 + Math.random();
							case "nanman":
								return 2 + Math.random();
							case "wanjian":
								return 1.6 + Math.random();
							default:
								return 1.5 + Math.random();
						}
					})
					//.set("filterButton", button => {
					//    return !_status.event.names.includes(button.link[2]);
					//})
					.set("names", storage[2])
					.set("custom", {
						add: {
							confirm: function (bool) {
								if (bool != true) return;
								const event = get.event().parent;
								if (event.controls) event.controls.forEach(i => i.close());
								if (ui.confirm) ui.confirm.close();
								game.uncheck();
							},
							button: function () {
								if (ui.selected.buttons.length) return;
								const event = get.event();
								if (event.dialog && event.dialog.buttons) {
									for (let i = 0; i < event.dialog.buttons.length; i++) {
										const button = event.dialog.buttons[i];
										const counterNode = button.querySelector(".caption");
										if (counterNode) {
											counterNode.childNodes[0].innerHTML = ``;
										}
									}
								}
								if (!ui.selected.buttons.length) {
									const evt = event.parent;
									if (evt.controls) evt.controls[0].classList.add("disabled");
								}
							},
						},
						replace: {
							button: function (button) {
								const event = get.event(),
									sum = event.sum;
								if (!event.isMine()) return;
								if (button.classList.contains("selectable") == false) return;
								if (ui.selected.buttons.length >= sum) return false;
								button.classList.add("selected");
								ui.selected.buttons.push(button);
								let counterNode = button.querySelector(".caption");
								const count = ui.selected.buttons.filter(i => i == button).length;
								if (counterNode) {
									counterNode = counterNode.childNodes[0];
									counterNode.innerHTML = `×${count}`;
								} else {
									counterNode = ui.create.caption(`<span style="font-size:24px; font-family:xinwei; text-shadow:#FFF 0 0 4px, #FFF 0 0 4px, rgba(74,29,1,1) 0 0 3px;">×${count}</span>`, button);
									counterNode.style.right = "5px";
									counterNode.style.bottom = "2px";
								}
								const evt = event.parent;
								if (evt.controls) evt.controls[0].classList.remove("disabled");
								game.check();
							},
						},
					})
					.set("sum", sum);
				if (result.bool) {
					var names = result.links.map(link => link[2]);
					storage[0] -= names.length;
					storage[1] = names;
					storage[2] = names;
				} else storage[2] = [];
				player.markSkill("sbkanpo");
			},
			marktext: "破",
			intro: {
				markcount: function (storage) {
					return storage[1].length;
				},
				mark: function (dialog, content, player) {
					const storage = player.getStorage("sbkanpo");
					const sum = storage[0];
					const names = storage[1];
					dialog.addText("剩余可记录" + sum + "次牌名");
					if (player.isUnderControl(true) && names.length) {
						dialog.addText("本轮记录牌名：");
						dialog.addSmall([names, "vcard"]);
					}
				},
			},
			group: "sbkanpo_kanpo",
			subSkill: {
				kanpo: {
					audio: "sbkanpo",
					trigger: { global: "useCard" },
					filter: function (event, player) {
						return event.player != player && player.storage.sbkanpo[1].includes(event.card.name);
					},
					prompt2: function (event, player) {
						return "移除" + get.translation(event.card.name) + "的记录，令" + get.translation(event.card) + "无效";
					},
					check: function (event, player) {
						var effect = 0;
						if (event.card.name == "wuxie" || event.card.name == "shan") {
							if (get.attitude(player, event.player) < -1) effect = -1;
						} else if (event.targets && event.targets.length) {
							for (var i = 0; i < event.targets.length; i++) {
								effect += get.effect(event.targets[i], event.card, event.player, player);
							}
						}
						if (effect < 0) {
							if (event.card.name == "sha") {
								var target = event.targets[0];
								if (target == player) return !player.countCards("h", "shan");
								else return target.hp == 1 || (target.countCards("h") <= 2 && target.hp <= 2);
							} else return true;
						}
						return false;
					},
					logTarget: "player",
					content: function () {
						player.storage.sbkanpo[1].remove(trigger.card.name);
						player.markSkill("sbkanpo");
						trigger.targets.length = 0;
						trigger.all_excluded = true;
						player.draw();
					},
				},
			},
		},
		sw_nanchong: {
			audio: ["dchaochong", 2],
			trigger: { player: "useCardAfter" },
			filter: function (event, player) {
				return player.maxHp != player.countCards("h");
			},
			direct: true,
			locked: false,
			content: function () {
				"step 0";
				var del = player.maxHp - player.countCards("h");
				event.delta = del;
				if (del > 0) {
					player.chooseBool(get.prompt("sw_nanchong"), "摸" + get.cnNumber(del) + "张牌，然后令你的体力上限-1").set("ai", () => {
						var player = _status.event.player;
						if (player.isPhaseUsing() && player.hasCard(cardx => player.hasUseTarget(cardx) && player.hasValueTarget(cardx), "hs")) return false;
						return true;
					});
				} else if (del < 0) {
					player
						.chooseToDiscard(get.prompt("sw_nanchong"), "弃置" + get.cnNumber(-del) + "张手牌，然后令你的体力上限+1", -del)
						.set("ai", card => {
							var player = _status.event.player;
							if (player.isPhaseUsing() && player.hasCard(cardx => player.hasValueTarget(cardx), "hs")) return 6 - player.getUseValue(card);
							return 5 - get.value(card);
						})
						.set("logSkill", "sw_nanchong");
				}
				"step 1";
				if (result.bool) {
					if (event.delta > 0) {
						player.logSkill("sw_nanchong");
						player.draw(event.delta);
						//lib.skill.sw_nanchong.change(player, -1);
						player.loseMaxHp();
					} else if (event.delta < 0) {
						//lib.skill.sw_nanchong.change(player, 1);
						player.gainMaxHp();
					}
				}
			},
			change: function (player, num) {
				if (typeof player.storage.sw_nanchong !== "number") player.storage.sw_nanchong = 0;
				if (!num) return;
				player.storage.sw_nanchong += num;
				player.markSkill("sw_nanchong");
				game.log(player, "的手牌上限", "#g" + (num > 0 ? "+" : "") + num);
			},
			markimage: "image/card/handcard.png",
			intro: {
				content: function (storage, player) {
					var num = player.storage.sw_nanchong;
					return "手牌上限" + (num >= 0 ? "+" : "") + num;
				},
			},
			mod: {
				maxHandcard: function (player, num) {
					return num + player.countMark("sw_nanchong");
				},
			},
			ai: { threaten: 2.2 },
		},
		sw_weige: {
			audio: ["dcjinjin", 2],
			trigger: {
				source: "damageSource",
				player: "damageEnd",
			},
			usable: 2,
			logTarget: "source",
			check: function (event, player) {
				if (player.maxHp == 7) return true;
				var evt = event.getParent("useCard");
				if (evt && evt.player == player && event.source == player) return false;
				if (player.isPhaseUsing() && player.maxHp - 7 == -1) return true;
				return Math.abs(7 - player.maxHp) >= 2;
			},
			prompt2: function (event, player) {
				var str = "";
				if (player.maxHp != 7) {
					str += "重置因〖男宠〗增加或减少的体力上限，";
				}
				var num = Math.abs(7 - player.maxHp) || 1;
				if (event.source && event.source.isIn()) {
					str += "令伤害来源弃置至多" + get.cnNumber(num) + "张牌，然后你摸" + num + "-X张牌（X为其弃置的牌数）";
				} else str += "你摸" + get.cnNumber(num) + "张牌";
				return str;
			},
			content: function () {
				"step 0";
				var del = Math.abs(7 - player.maxHp) || 1;
				event.delta = del;
				//player.storage.dchaochong = 0;
				if (7 - player.maxHp > 0) player.gainMaxHp(7 - player.maxHp);
				else player.loseMaxHP(player.maxHp - 7);
				if (player.hasSkill("sw_nanchong", null, false, false)) player.markSkill("sw_nanchong");
				game.log(player, "重置了体力上限");
				if (trigger.source && trigger.source.isIn()) {
					trigger.source
						.chooseToDiscard(get.translation(player) + "对你发动了【伟哥】", "弃置至多" + get.cnNumber(del) + "张牌，然后" + get.translation(player) + "摸" + del + "-X张牌（X为你弃置的牌数）。", [1, del], "he")
						.set("ai", card => {
							if (_status.event.goon) return 5.5 - get.value(card);
							return 0;
						})
						.set("goon", get.attitude(trigger.source, player) < 0);
				}
				"step 1";
				var num = event.delta;
				if (result.bool) num -= result.cards.length;
				if (num > 0) player.draw(num);
			},
			ai: {
				combo: "sw_nanchong",
				maixie: true,
				maixie_hp: true,
				threaten: 0.85,
				effect: {
					target: function (card, player, target) {
						if (get.tag(card, "damage")) {
							if (player.hasSkillTag("jueqing", false, target)) return [1, -2];
							if (!target.hasFriend()) return;
							var num = 0;
							if (typeof target.storage.dcninchong == "number") num = Math.abs(target.storage.dcninchong);
							if (num <= 0) return;
							return [1, Math.min(1, num / 3)];
						}
					},
				},
			},
		},
		sw_tonghun_xianfu: {
			charlotte: true,
			trigger: { global: ["drawEnd", "recoverEnd"] },
			forced: true,
			filter(event, player) {
				if (event.player.isDead() || !player.storage.sw_tonghunTargets || !player.storage.sw_tonghunTargets.includes(event.player) || event.num <= 0) return false;
				return true
			},
			async content(event, trigger, player) {
				const name = event.triggername
				if (name === 'drawEnd') {
					await player.draw(trigger.num)
				}
				if (name === 'recoverEnd') {
					await player.recover(trigger.num)
				}
			},
			popup: false,
		},
	},
	characterSubstitute: {
		swq_xindong: [
			["swq_xindong_shadow",  [`img: ${ec}swq_xindong_shadow.jpg`]],
		],
	},
	characterSort: {
		swDIY: {
			qqGroup: ["swq_aoliao", "swq_lugushou", "swq_xindong", "swq_sunyuning"],
			swyigou: ["swyg_jushou", "swyg_guojia", "swyg_xunyu", "swyg_caojinyu", "swyg_hanxiandi", "swyg_xiaoqiao"],
			sweryou: ["swe_katixiya"],
		}
	},
	//武将介绍
	characterIntro: {
		swq_aoliao: '又名老弟，无名杀主群创始人之一。唉，今天又被朗神鸽了。',
		swq_lugushou: '又名🦌🥁✋，鹿关手。闹麻了。',
		swq_xindong: '太阳系地球人，未知年-未知年，每晚准时开房，快来挨打吧！',
		swq_sunyuning: '逃跑男，坑队友男。黑猫白猫，不如孙玉凝喵~',
		swyg_hanxiandi: '汉献帝刘协（181年4月2日—234年4月21日），字伯和，东汉末代皇帝。' +
			'刘协出生时母亲王美人遭何皇后毒杀，于是董太后亲自抚养刘协，号称“董侯”。初平元年（190年），随董卓迁往长安。兴平二年（195年），车驾东归。护驾途中，诸将专权，相互攻伐，肆意妄为，最终使得朝廷在建安元年（196年）被曹操控制。同年，迁都许县，正式挟天子以令诸侯。建安十三年（208年），刘协罢免三公，册立曹操为丞相，后又封曹操为魏公。建安二十五年（220年），魏王曹操薨逝，曹丕逼迫刘协禅位，正式建立曹魏，刘协被废为山阳公。',
		swe_katixiya: '卡提希娅是游戏《鸣潮》及其衍生作品中的角色。鸣式利维亚坦所创造的共鸣者。据传故乡在拂风水畔。凡于隐海修会任职的高阶教士，都会领受新的“名号”，传说中的“圣女”芙露德莉斯，领受新名前的本名是“卡提希娅”。但卡提希娅其实并非人们口中流传的岁主选中的圣女，而是由来自深海的鸣式“利维亚坦”创造的共鸣者。',
		swe_fuludelisi: '芙露德莉斯是游戏《鸣潮》及其衍生作品中的角色。本名卡提希娅，因鸣式"利维亚坦"的共鸣选择脱离凡人身份，其成长历程被揭示为多方势力操控的产物。在成为隐海修会"圣女"期间，曾于二十年前以自我献祭方式完成黑潮封印，该事件至今仍在游戏世界观中产生深远影响。档案资料暗示其神圣表象下保留着农家少女时期的性格特质，这在醉酒事件中得到戏剧化呈现。',
	},
	//武将替换
	characterReplace: {

	},
	//翻译统一规范：
	//技能名用〖〗，牌名用【】，标记用“”，特殊区域的牌用「」
	translate: {
		swDIY: '云中守望',
		qqGroup: 'Q群风云传',
		swyigou: '异构奇英录',
		sweryou: '二游同人创',


		//Q群风云传
		swq_aoliao: "奥利奥",
		swq_zhitian: "知天",
		swq_zhitian_backup: "知天",
		swq_zhitian_info: "①你可以将牌堆顶的牌当任意非装备牌使用，若此牌牌名不同于你使用的牌名，〖知天〗于本回合失效且你失去一点体力。②当你的体力值变化时，你可以观看牌堆顶X张牌（X为你变化后的体力值+2），并以任意顺序将牌置于牌堆顶或者牌堆底。",
		swq_jincui: "尽瘁",
		swq_jincui_info: "限定技，出牌阶段，你可以失去1点体力并选择一名其他角色，然后亮出牌堆顶的七张牌，依次对其使用其中的【杀】。结算完毕后若仍有未使用的牌，你可以从中选择一张并获得之，之后将其余牌置入弃牌堆。",
		swq_qideng: "七灯",
		swq_qideng_info: "锁定技，游戏开始时，你获得七个“灯”。当你进入濒死状态时，若你有“灯”，你须回复体力至1点并移除等同于回复量的“灯”（不足则全移除），否则你失去1点体力。",

		swq_lugushou: '陆古寿',
		swq_duannian: '断念',
		swq_duannian_info: '持恒技，限定技，当你脱离濒死状态时，你可以选择依次执行至多X项：1.摸剩余选项张牌；2.获得一名其他角色的一个技能；3.重置该技能并删除最后一个选项；4.升级〖讥讽〗。（X为本局游戏你进入濒死状态的次数）',
		swq_jifeng: '讥讽',
		swq_jifeng_info: '出牌阶段，你可以摸一张牌并与一名其他未处于〖讥讽〗失效状态的角色拼点，若你赢，你令其非锁定技失效直到你的下个回合开始；反之，你的非锁定技失效直到你的下个回合开始。',
		swq_jifeng_lv2: '讥讽2级',
		swq_jifeng_lv2_info: '出牌阶段，你可以摸两张牌并与一名其他未处于〖讥讽〗失效状态的角色拼点，若你赢，你令其非Charlotte技失效直到你的下个回合开始；反之，你的非锁定技失效直到你的下个回合开始。',
		swq_juejing: '绝境',
		swq_juejingGlobal: '绝境',
		swq_juejing_info: '此技能仅失效时生效。当你进入濒死状态时，你可以将体力回复至1点并摸两张牌，然后重置你因〖讥讽〗的失效状态。',
		swq_juejingGlobal_info: '此技能仅失效时生效。当你进入濒死状态时，你可以将体力回复至1点并摸两张牌，然后重置你因〖讥讽〗的失效状态。',

		swq_xindong: '心动',
		swq_qingnian: '倾念',
		visible_swq_qingnian: '倾念',
		swq_qingnian_info: '转换技。①游戏开始时，你可以转换此技能状态；②每回合每项各限一次，当你不因使用而失去手牌时，你可以：阳，将手牌摸至体力上限并随机明置一名其他角色的X张手牌；阴，明置一张手牌并弃置一名其他角色的至多X张牌，然后你将被弃置的牌以任意顺序置于牌堆顶或牌堆底。（X为你本次失去牌的数量）',
		swq_lunqi: '论契',
		swq_lunqi_info: '出牌阶段限一次，你可以弃置一种花色的所有手牌，令所有角色参与议事（若你有明置的手牌，则你只能使用明置的手牌议事），然后你可以交换任意两名角色的至多X张手牌。（X为红黑意见之差的绝对值）',
		swq_xinci: '心赐',
		visible_swq_xinci: '心赐',
		swq_xinci_info: '主公技，其他key势力角色的回合开始时，你可以将一张手牌交给该角色并明置之。然后此回合结束时，若其于此回合没有回复过体力，你失去1点体力。',

		swq_sunyuning: '孙玉凝',
		swq_wudu: '巫毒',
		swq_wudu_info: '①游戏开始时，你将游戏中存在的各种身份的身份牌各8张加入牌堆。你可以重铸身份牌。摸到身份牌的效果对你无效。②出牌阶段限一次，你可以向牌堆中添加四张任意花色和点数的一种身份牌。',
		swq_yuyin: '御因',
		swq_yuyin_info: '持恒技，其他角色的回合结束时，若本回合有身份牌进入弃牌堆，你观看其手牌并可以视为使用其中一张牌（其手牌中的身份牌根据以下规则于此流程中视为：主公，【推心置腹】；忠臣，【无中生有】；反贼，【奇正相生】；内奸，【万箭齐发】；其他，【铁索连环】），若此牌的目标包含其，其摸一张牌。',

		//异构奇英录
		swyg_jushou: '异构沮授',
		swyg_jushou_prefix: '异构',
		swyg_jianying: '渐营',
		swyg_jianying_info: '每当你于出牌阶段内使用牌时，根据此牌字数与此阶段你使用的上一张牌的字数关系，你可以触发指定效果：相同，你摸一张牌；相差为1，你本回合使用的下一张牌无距离和次数限制；相差为2或更多，你重置〖权略〗。',
		swyg_quanlue: '权略',
		swyg_quanlue_info: '出牌阶段限一次，你可以弃置一张牌，然后从牌堆中获得一张任意字数的牌。',
		swyg_shibei: '矢北',
		swyg_shibei_info: '锁定技，当你于一回合内第一次受到伤害后，你回复1点体力；当你于一回合内第二次受到伤害后，你失去1点体力并摸一张牌。',

		swyg_guojia: '异构郭嘉',
		swyg_guojia_prefix: '异构',
		swyg_shisheng: '十胜',
		swyg_shisheng_info: '出牌阶段限一次，你可与一名其他角色比较手牌数、血量、装备区牌数，然后你依次执行以下选项中的前X项：1.获得技能〖天妒〗直到再发动此技能。2.摸两张牌。3.回复1点体力。（X为比较中你大于其的次数）。',
		swyg_shibai: '十败',
		swyg_shibai_info: '当你受到伤害后，你可以在〖遗计〗、〖节命〗、〖反馈〗、〖奸雄〗、〖筹策〗中选择一个发动。',

		swyg_xunyu: '异构荀彧',
		swyg_xunyu_prefix: '异构',
		swyg_zaifu: '宰辅',
		swyg_zaifu_info: '当你受到伤害后，你可以令一名角色将手牌调整至体力上限（至多摸五张），若以此法摸牌，你将摸到的牌标记为“宰辅”，有角色失去过“宰辅”牌的回合结束时，你可以令一名角色视为对另一名角色使用一张随机的伤害类锦囊牌；若以此法弃牌，则你可以分配其中至多X张牌（X为其体力值）。',
		swyg_dingce: '定策',
		swyg_dingce_info: '①你可将一张牌当做任意同字数且你未记录过的任意基本或普通锦囊牌使用或打出，然后你记录之。②准备阶段，你可在记录中减少一种牌名。',

		swyg_caojinyu: '异构曹金玉',
		swyg_caojinyu_prefix: '异构',
		swyg_yuqi: '隅泣',
		swyg_shanshen_tag: '隅泣',
		swyg_yuqi_info: '当你受到伤害后，你可弃置至多X名本回合未受伤过的角色的一张手牌（X为你的体力值），若弃置的牌中有【杀】或【桃】，你可以使用之（每回合各限使用一次），然后你将未使用的牌置于你的武将牌上，称为「隅泣」。',
		swyg_shanshen: '善身',
		swyg_shanshen_info: '准备阶段，你可以使用至多X张牌交换「隅泣」（X为你已损失的体力值且至少为1），然后根据「隅泣」中伤害牌和其他牌的大小关系触发指定效果：大于，则你本回合：使用【杀】的次数加一，使用的第一张【杀】不可响应；等于：你摸两张牌并跳过本回合的弃牌阶段；小于：你回复一点体力且本回合无法对其他角色使用手牌。',
		swyg_xianjing: '娴静',
		swyg_xianjing_info: '觉醒技，当你武将牌上的「隅泣」数量大于等于7时，你增加一点体力上限并回复一点体力，然后你可以弃置任意数量的「隅泣」并摸等量牌。',

		swyg_hanxiandi: '异构汉末献帝',
		swyg_hanxiandi_prefix: '异构',
		swyg_modi: '末帝',
		swyg_modi_info: '锁定技，其他角色的回合开始时，其可交给你一张牌然后你摸一张牌并交给其一张牌，否则其需对除你以外的角色使用一张【杀】或失去1点体力。',
		swyg_zhaoling: '诏令',
		swyg_zhaoling_tag: '诏令',
		swyg_zhaoling_info: '出牌阶段限三次，你可将任意张牌交给一名其他角色，称为“诏令”。当有角色使用或打出“诏令”后你摸一张牌并获得一枚“汉”标记',
		swyg_fuhan: '复汉',
		swyg_fuhan_info: '觉醒技，准备阶段，若你的“汉”数量大于等于场上势力数，你增加三点体力上限并回复1点体力，失去〖末帝〗并获得技能〖天子〗',
		swyg_tianzi: '天子',
		swyg_tianzi_info: '锁定技，摸牌阶段摸牌时，你额外摸等同于你体力值张牌（至多多摸三张）；你使用牌无距离限制；你始终跳过弃牌阶段。',
		swyg_handi: '汉帝',
		swyg_handi_info: '主公技，每回合限一次，当有角色使用“诏令”后，其使用的下一张牌无距离和次数限制',

		swyg_xiaoqiao: '异构小乔',
		swyg_xiaoqiao_prefix: '异构',
		swyg_tianxiang: '天香',
		swyg_tianxiang_info: '①当你即将受到伤害时，若你有手牌，你可以展示所有手牌，若花色均为♥，则你将此伤害转移给一名其他角色、摸两张牌并使手牌上限-1；反之，你可以重铸至多X张牌（X为你的手牌上限和体力值之差且至少为1）。②锁定技，当你受到伤害后，你的手牌上限+Y（Y为伤害值）。',
		swyg_hongyan: '红颜',
		swyg_hongyan_info: '锁定技，你获得以下前X项效果：你区域内的①♠②♣③♦牌和对应花色的判定牌均视为♥。（X为你的手牌上限和体力值之差且至少为1）',
		
		// 二游同人创
		swe_katixiya: '卡提希娅',
		[`#${ea}katixiya/katixiya:die`]: "巡礼的终点……",
		swe_fengdu: '奉读',
		swe_fengdu_info: '①每回合限一次，你使用牌指定其他角色为唯一目标或成为其他角色使用牌的唯一目标时，你可以选择一项：1.令此牌额外增加一个目标；2.令此牌回复值/伤害值+1。若你选择的选项与你上一次选择的不同，你摸一张牌并获得“神权剑”。②当你造成或受到大于1的伤害后，你获得“异权剑”。',
		[`#${ea}katixiya/swe_fengdu1`]: "坠落吧，恶徒！",
		[`#${ea}katixiya/swe_fengdu2`]: "别想逃离！",
		swe_yijian: '以剑',
		swe_yijian_info: '出牌阶段限一次，你可以令一名角色从牌堆中获得其手牌中没有的花色的牌各一张，若其获得了两张及以上的牌，你获得“人权剑”。',
		[`#${ea}katixiya/swe_yijian1`]: "涤除不净。",
		[`#${ea}katixiya/swe_yijian2`]: "高天沉垂。",
		swe_qiyuan: '祈愿',
		swe_qiyuan_info: '限定技，出牌阶段，若你本回合使用过四种花色的牌或拥有全部剑影，你可以将体力降低调整至体力上限的一半（不足则不执行）并将武将牌替换为【芙露德莉斯】。',
		[`#${ea}katixiya/swe_qiyuan1`]: "汪洋，没向我身。",
		[`#${ea}katixiya/swe_qiyuan2`]: "真容，于此展露。",

		swe_fuludelisi: '芙露德莉斯',
		[`#${ea}katixiya/fuludelisi:die`]: "剑身，已然折断。",
		swe_jueyi: '决意',
		swe_jueyi_info: '持恒技。①你切换至此角色后，根据你切换前拥有的剑影获得以下效果：神权剑，获得20点“决意”，当你受到伤害时，你可以弃置一张装备牌防止之；异权剑，获得20点“决意”，每回合首次造成的伤害+1；人权剑，获得20点“决意”，你始终跳过判定和弃牌阶段。效果均至多存在两轮。②每当你失去最后一种花色的手牌后/造成大于1的伤害后/武将状态发生改变后，你获得10/20/40点“决意”（上限为120点）。③若你的决意不小于120点，你视为拥有〖潮怒〗。',
		[`#${ea}katixiya/swe_jueyi1`]: "裁罚净罪！",
		[`#${ea}katixiya/swe_jueyi2`]: "涛澜无恕！",
		[`#${ea}katixiya/swe_jueyi3`]: "毁灭，敲响。",
		[`#${ea}katixiya/swe_jueyi4`]: "潮涌，覆落。",
		swe_jueyi_jump: '人权之心',
		swe_jueyi_damage: '异权之力',
		swe_jueyi_immunity: '神权之意',
		swe_chaonu: '潮怒',
		swe_chaonu_info: '限定技，出牌阶段，你可以消耗120点“决意”、弃置任意张牌并选择一名其他角色，你对其造成X点伤害（X为你弃置的牌数与其手牌中花色数中的较小值且至少为1），然后你失去所有〖决意①〗中的效果并将武将牌替换为【卡提希娅】。',
		[`#${ea}katixiya/swe_chaonu1`]: "此剑，斩灭诸恶！",
		[`#${ea}katixiya/swe_chaonu2`]: "狂澜，分割天地！",




		sw_shenshouwang: "神守望",
		sw_shenshouwang_prefix: "神",
		sw_tonghun: "同婚",
		sw_tonghun_info: "游戏开始时，你可以选择一名其他角色与其获得一枚“嫁”，然后本局游戏其恢复体力时你回复等量体力，其摸牌时你摸等量的牌。",

		sw_shouwang: "守望",
		sw_tongpin: "同嫁",
		sw_tongpin2: "同嫁",
		sw_tongpin_info: `①出牌阶段限一次，你可以翻面并选择一名其他角色使其获得一枚“同嫁”标记，拥有“同嫁”标记的角色回合内【杀】使用次数+1，【杀】的伤害+1。<br>
							②每轮限一次，拥有“同嫁”标记的角色即将受到伤害时，你可以弃置X张牌（X为伤害数），将伤害转移自己。<br>
							③拥有“同嫁”标记的角色受到伤害后，其移除“同嫁”标记，你复原你的武将牌。若你本轮未发动过【同嫁②】，你回复1点体力。<br>
							④若场上存在“同嫁”标记，你的武将状态无法被更改，当你受到伤害时，防止之。
							`,
		sw_kelian: "惜玉",
		sw_kelian_info: "锁定技。当你即将受到伤害前，你令伤害来源跳过下个摸牌阶段，且直到你的下个回合开始，你计算与其他角色距离+X（X为累积总伤害点数）。",

		sw_lutiandilang: "鹿天帝朗",
		sw_lutiandilang_prefix: "鹿天帝",
		sw_renjie: "戒忍",
		sw_renjie_info: "锁定技。当你即将造成伤害时，取消之，并获得等同于伤害数量两倍的“精气”。当你受到伤害时，获得一枚“精气“（“精气“上限为5）。你每次受到的伤害最多不会超过2点。你的手牌上限+X（X为“精气”标记个数）。",
		sw_sanyang: "散阳",
		sw_sanyang_info: "当你成为任意牌的目标时，若你有“精气”，你可以弃置一枚“精气”，取消此牌的所有目标。",
		sw_luguan: "鹿关",
		sw_luguan_info: `出牌阶段限一次。你可以弃置所有“精气”并表演鹿关，根据你鹿关完成的速度和弃置的“精气”数量对一名其他玩家等比造成0-2点火焰伤害（完成速度越快，标记越多，伤害越高），然后根据其性别额外执行如下效果：<br>
							①含女性：若其没有技能【害羞】，其获得之。<br>
							②其他：若其没有技能【愤懑】，其获得之。<br>
							当你在一局游戏中第三次使用该技能并结算完毕后，你死亡。<br>
							`,
		sw_xinhuo: "心火",
		sw_xinhuo_info: "锁定技。每当你使用偶数次牌时，你令武将牌上的前一个未失效的技能失效直到你的回合开始/回合结束。然后你摸等同于你当前失效技能个数的牌。当你因为【心火】导致此技能失效时，你减一点体力上限。",
		sw_haixiu: "害羞",
		sw_haixiu_info: "锁定技。每当你获得牌后，你获得等同于获得牌数的“害羞”标记。每获得8个害羞标记，你失去一点体力。",
		sw_fenmen: "愤懑",
		sw_fenmen_info: "锁定技。每当你造成伤害后，你获得等同于造成伤害数的“愤懑”标记。每获得3个愤懑标记，你失去一点体力。",

		sw_shenqinlang: "神秦朗",
		sw_shenqinlang_prefix: "神",
		sw_nanchong: "男宠",
		sw_nanchong_info: "当你使用牌后，你可以将手牌摸至或弃置至你的体力上限数。然后若你以此法：得到牌，你的体力上限-1；失去牌，你的体力上限+1。",
		sw_weige: "伟哥",
		sw_weige_info: "每回合限两次。当你造成或受到伤害后，你可以将体力上限重置为 7，令伤害来源弃置至多X张牌，然后你摸Y张牌（X为你以此法变化的体力上限且至少为1，Y为X减其以此法弃置的牌数）。",

		sw_gushenlangfeite: "股神朗菲特",
		sw_gushenlangfeite_prefix: "股神",
		sw_shangshi: "上市",
		sw_shangshi_info: "①你的回合结束时，你可以选择至多<span class=thundertext>3</span>张牌置于你的武将牌上并摸等量的牌，称为股，若你至少选择了一张牌入股且你没有护甲，你获得一点护甲。若你没有选择任何牌，则你可以进行一次判定并将判定牌置入股。②其他角色的回合开始时，若你的武将牌上有股，你令其选择一项：1.选择一张牌入股2.流失<span class=firetext>3</span>点体力。然后其进行一次判定，你将其选择的牌和判定牌置入股。③你的手牌上限始终+X（X为【上市①】中的数字）",
		sw_kaipan: "开盘",
		sw_kaipan_info: "锁定技。你的回合开始时，若你有股，你需猜测股票的涨跌情况并展示所有股，分别统计红色牌和黑色牌点数之和，若①红色牌点数和大于黑色牌点数和(涨)，所有入股角色摸等同于入股红色牌数量乘2的牌，且你1.猜测正确：你获得【金睛】【资本】直到回合结束。2.猜测错误：你令【上市①】中的数字减1。②黑色牌点数和大于等于红色牌点数数量的和(跌)，所有入股角色失去等同于入股红色牌数量的体力，且你1.猜测正确：你回复1点体力，获得技能【反馈】直到你的下回合开始。2.猜测错误：你令【上市②】中的数字减1。结算完毕后你弃置所有股。",
		sw_ziben: "资本",
		sw_ziben_info: "当你对其他角色造成伤害后，你可以获得目标区域内的一张牌。",

		sw_shenaoliao: "神奥利奥",
		sw_shenaoliao_prefix: "神",
		sw_kanpo: "看破",
		sw_kanpo_info: "①一轮游戏开始时，你清除〖看破①〗记录的牌名，然后你可以依次记录任意个牌名（对其他角色不可见），每轮至多记录4个牌名，总共最多记录12个牌名。若你没有记录次数，则你失去〖看破〗，从剩余牌堆中获得所有智囊牌各一张，并获得技能〖尽瘁〗。②其他角色使用你〖看破①〗记录过的牌名的牌时，你可以移去一个〖看破①〗中的此牌名的记录令此牌无效，然后你摸一张牌。",
		sw_zhinang: "智囊",
		sw_zhinang_info: "锁定技。当你使用非虚拟非转化且对应实体牌为1的智囊锦囊牌时，系统从技能描述中包含“无懈可击|过河拆桥|顺手牵羊|无中生有|乐不思蜀”字样的技能中随机选择三个你未拥有的技能，然后你令自己获得其中一个技能",
		sw_shenjincui: "尽瘁",
		sw_shenjincui_info: "锁定技。准备阶段，若牌堆剩余智囊数：大于9，你加一点体力上限并摸一张牌;大于等于7，你使用【杀】的次数上限+1;小于7，你减一点体力上限且至多减至三",



		sw_hepingshizhelang: "和平使者朗",
		sw_gugu: "咕咕",
		sw_gugu_info: "①游戏开始时/结束阶段，你可以将一张♦牌当做【乐不思蜀】对自己使用，然后摸1张牌。②当你成为牌的目标时，若目标数为1且你的判定区有牌，你令此牌无效。",
		sw_heping: "和平",
		sw_heping_info: "锁定技。游戏开始时，你令所有存活且未拥有“和平”的角色获得“和平”标记，拥有“和平”标记角色的♠牌和♠判定牌的花色视为♥，♣牌和♣判定牌的花色视为♦。你的♦牌不计入手牌上限。",
		sw_shangzhuo: "上桌",
		sw_shangzhuo_info: "觉醒技。当你受到伤害后，你须废除自己的判定区，然后将武将牌替换为从X张武将牌中选择的一张（X为你的手牌数+1），并将体力和体力上限调整至3点，回复1点体力。",








	},
	dynamicTranslate: {
		sw_shangshi(player) {
			var info = lib.skill.sw_shangshi.getInfo(player);
			return "①你的回合结束时，你可以选择至多<span class=thundertext>" + info[0] + "</span>张牌置于你的武将牌上并摸等量的牌，称为股，若你至少选择了一张牌入股且你没有护甲，你获得一点护甲。若你没有选择任何牌，则你可以进行一次判定并将判定牌置入股。②其他角色的回合开始时，若你的武将牌上有股，你令其选择一项：1.选择一张牌入股2.流失<span class=firetext>" + info[1] + "</span>点体力。然后其进行一次判定，你将其选择的牌和判定牌置入股。③你的手牌上限始终+等同于【上市①】中的数字";
		},



		swq_jifeng(player) {
			if (player.getStorage("swq_jifeng", 0) == 0) return get.skillInfoTranslation("swq_jifeng");
			else return get.skillInfoTranslation("swq_jifeng_lv2");
		},
		swq_duannian(player) {
			let list = ["1.摸剩余选项张牌", "2.获得一名其他角色的一个技能", "3.重置该技能并删除最后一个选项", "4.升级〖讥讽〗"];
			const num = player.getStorage("swq_duannian_dnum", 0);
			list.length = list.length - num;
			return `持恒技，限定技，当你脱离濒死状态时，你可以选择依次执行至多X项：${list.join(';')}。（X为本局游戏你进入濒死状态的次数）`;
		},
		swq_qingnian(player) {
			if (!player.storage.swq_qingnian) return `转换技。①游戏开始时，你可以转换此技能状态；②每回合每项各限一次，当你不因使用而失去手牌时，你可以：<span class="bluetext">阳，将手牌摸至体力上限并随机明置一名其他角色的X张手牌；</span>阴，明置一张手牌并弃置一名其他角色的至多X张牌，然后你将被弃置的牌以任意顺序置于牌堆顶或牌堆底。（X为你本次失去牌的数量）`;
			return `转换技。①游戏开始时，你可以转换此技能状态；②每回合每项各限一次，当你不因使用而失去手牌时，你可以：阳，将手牌摸至体力上限并随机明置一名其他角色的X张手牌；<span class="bluetext">阴，明置一张手牌并弃置一名其他角色的至多X张牌，然后你将被弃置的牌以任意顺序置于牌堆顶或牌堆底。</span>（X为你本次失去牌的数量）`;
		},
		swyg_hongyan(player) {
			const num = Math.abs(player.getHandcardLimit() - player.getHp()) || 1;
			const lists = ["①♠", "②♣", "③♦"];
			const quoted = lists.map((opt, i) => (i < num ? `<span class=thundertext>${opt}</span>` : opt));
			return `锁定技，你获得以下前X项效果：你区域内的${quoted.join("")}牌和对应花色的判定牌均视为♥。（X为你的手牌上限和体力值之差且至少为1）`;
		},
	},
	func: function() {
		lib.namePrefix.set('异构',{
			color: "#e7c3ff",
			nature: "thundermm",
			showName: '异',
		})

	},
}
